Example #1
0
 void attributes(xmap.IFeature obj)
 {
     string info = obj.Info;
     if (convert.IsString(info))
     {
         fwriter.WritePropertyName("attributes");
         fwriter.WriteRawValue(info);
     }
     else writeNullObject("attributes");
 }
Example #2
0
        void ref_feature(xmap.Ixmap_auto map, xmap.IFeature obj, xmap.IFeature obj1)
        {
            fGeometry.Clear();
            geometry_ref(obj);

            int top;
            int ptr = map.get_frst_geometry(obj.Offset, out top);
            while (ptr > 0)
            {
                obj1.Get(ptr);
                geometry_ref(obj1);
                ptr = map.get_next_geometry(ptr, top);
            }

            feature(map, obj);
        }
Example #3
0
        Point __point(xmap.IPoly mf)
        {
            var pt = new Point();
            pt.Type = GeometryType.Point;

            if (mf.PartCount > 0)
            {
                double x, y;
                mf.GetPointd(0, 0, out y, out x);
                pt.X = x*RadToDeg; pt.Y = y*RadToDeg;
            }

            return pt;
        }
Example #4
0
 Polyline __polyline(xmap.IPoly mf)
 {
     var pp = new Polyline();
     pp.Type = GeometryType.Polyline;
     pp.Paths = __paths(mf);
     return pp;
 }
Example #5
0
        void writeEdge(xmap.IPoly mf, int part, bool locked, string id)
        {
            string n1 = vcTag + id;
            string n2 = n1;
            if (!locked) {
                n1 += "_1";
                n2 += "_2";
            }

            fwriter.WriteStartObject();

            writeValues("interpolationType", "loxodromic");
            writeValues("startPoint", n1);
            writeValues("endPoint", n2);

            int n;
            mf.GetContourCount(part, out n);

            if (n > 2)
            {
                fwriter.WritePropertyName("internalPoints");
                fwriter.WriteStartArray();

                for (int i = 1; i < n - 1; i++)
                    writePoint(Point2d(mf, part, i));

                fwriter.WriteEndArray();
            }

            fwriter.WriteEndObject();
        }
Example #6
0
 void __nextGeometry(string key, xmap.IFeature obj)
 {
     int lower, upper;
     obj.GetScaleRange(out lower, out upper);
     Geometry g = new Geometry(lower, upper, key);
     fGeometry.Add(g);
 }
Example #7
0
        bool move_edge(xmap.IPoly mf1,
                       xmap.IPoly mf2,
                       int part, string id)
        {
            bool rc = false, rc1 = false;

            int n1;
            mf1.GetContourCount(part, out n1);

            int n2;
            mf2.GetContourCount(part, out n2);

            if (n1 * n2 > 0)
            {
                bool locked1 = edgeLocked(mf1, part);
                bool locked2 = edgeLocked(mf2, part);

                point2d a1 = Point2d(mf1, part, 0);
                point2d b1 = Point2d(mf1, part, n1 - 1);

                point2d a2 = Point2d(mf2, part, 0);
                point2d b2 = Point2d(mf2, part, n2 - 1);

                string id1 = id, id2 = id;
                if (!locked2) {
                    id1 += "_1";
                    id2 += "_2";
                }

                if (locked1 == locked2)
                {
                    if (!PointEquals(a1, a2)) rc = move_node(a1, a2, id1);
                    if (!PointEquals(b1, b2)) rc = move_node(b1, b2, id2);
                }
                else
                {
                    if (locked2)
                        node(a2, id);
                    else
                    {
                        node(a2, id + "_1");
                        node(b2, id + "_2");
                    }

                    rc = true; rc1 = true;
                }

                if (!rc1 && (n1 == n2))
                rc1 = !PartEquals(mf1, mf2, part);

                if (rc1)
                {
                    fwriter.WritePropertyName(veTag + id);
                    fwriter.WriteStartArray();

                    writeEdge(mf1, part, locked1, id);
                    writeEdge(mf2, part, locked2, id);

                    fwriter.WriteEndArray();
                    rc = true;
                }
            }

            return rc;
        }
Example #8
0
        string shape(xmap.IFeature obj)
        {
            int loc = obj.Loc % 100;

            string key = obj.guid;
            if (convert.IsString(key))
            {
                xmap.IPoly mf = obj.mf; mf.IsWGS = 1;

                if (mf.PartCount > 0)
                switch (loc)
                {
                case 1:
                    return node(Point2d(mf, 0, 0), key);
                case 2:
                    return edge(mf, 0, key);
                case 3:
                    return surface(mf, key);
                }
            }

            return null;
        }
Example #9
0
        void geometry_ref(xmap.IFeature obj)
        {
            string key = obj.guid;

            if (convert.IsString(key))
            switch (obj.Loc % 100)
            {
                case 1:
                    __nextGeometry(vcTag + key,obj);
                    break;
                case 2:
                    __nextGeometry(veTag + key,obj);
                    break;
                case 3:
                    __nextGeometry(ssTag + key,obj);
                    break;
            }
        }
Example #10
0
        List<int> get_geoms(xmap.Ixmap_auto map, int offset)
        {
            int top;
            int ptr = map.get_frst_geometry(offset, out top);

            if (ptr > 0) {
                List<int> list = new List<int>();

                while (ptr > 0)
                {
                    list.Add(ptr);
                    ptr = map.get_next_geometry(ptr, top);
                }

                return list;
            }

            return null;
        }
Example #11
0
        void feature(xmap.Ixmap_auto map, xmap.IFeature obj)
        {
            fwriter.WriteStartObject();

            writeValues("code", obj.acronym);
            writeValues("globalId", obj.guid);
            attributes(obj);
            write_geometry();
            relations(map,obj.Offset);

            fwriter.WriteEndObject();
        }
Example #12
0
        bool edgeLocked(xmap.IPoly mf, int part)
        {
            int n;
            mf.GetContourCount(part, out n);

            if (n >= 2)
            {
                point2d a = Point2d(mf, part, 0);
                point2d b = Point2d(mf, part, n - 1);

                return ((a.x == b.x) && (a.y == b.y));
            }

            return false;
        }
Example #13
0
        string edge(xmap.IPoly mf, int part, string id)
        {
            int n;
            mf.GetContourCount(part, out n);

            if (n > 0) {

                bool locked = edgeLocked(mf,part);

                point2d a = Point2d(mf, part, 0);
                point2d b = Point2d(mf, part, n - 1);

                if (locked)
                    node(a, id);
                else {
                    node(a, id + "_1");
                    node(b, id + "_2");
                }

                string key = veTag + id;
                fwriter.WritePropertyName(key);
                fwriter.WriteStartArray();

                writeEdge(mf, part, locked, id);

                fwriter.WriteEndArray();

                return key;
            }

            return "";
        }
Example #14
0
        void relations(xmap.Ixmap_auto map, int offset)
        {
            int top, rc = 0;
            int ptr = map.get_frst_relation(offset,out top);
            while (ptr > 0) {
                int locid, dir, typ;
                string guid, code, name;
                map.get_relation(ptr, out locid, out dir, out typ, out guid, out code, out name);

                if ((dir == 1) &&
                    (typ >= 1) && (typ <= 3) &&
                    convert.IsString(guid)) {

                    if (rc == 0)
                    {
                        fwriter.WritePropertyName("featureAssociations");
                        fwriter.WriteStartArray();
                    }

                    fwriter.WriteStartObject();
                    writeValues("ref", feTag + guid);
                    writeValues("associationCode", code);

                    string role = "Association";
                    if (typ == 2) role = "Aggregation";
                    else
                    if (typ == 3) role = "Composition";

                    writeValues("roleCode", role);
                    writeNullObject("attributes");

                    fwriter.WriteEndObject();
                    rc++;
                }

                ptr = map.get_next_relation(ptr, top);
            }

            if (rc > 0) fwriter.WriteEndArray();
        }
Example #15
0
        int move_geoms(int offset1,
                       xmap.Ixmap_auto map1,
                       xmap.IFeature obj1,

                       int offset2,
                       xmap.Ixmap_auto map2,
                       xmap.IFeature obj2)
        {
            int rc = 0;

            List<int> list1 = get_geoms(map1,offset1);
            List<int> list2 = get_geoms(map2,offset2);

            if (list2 != null)
            {
                int i = 0;
                while (i < list2.Count)
                {
                    obj2.Get(list2[i]);
                    string guid = obj2.guid;

                    int j = -1;
                    if (convert.IsString(guid))
                    j = seek_guid(obj1, list1, guid);

                    if (j < 0)
                    {
                        shape(obj2); rc |= 2;
                    }
                    else
                    {
                        if (move_shape(obj1, obj2)) rc |= 1;
                        list1.RemoveAt(i); i--;
                        list2.RemoveAt(j);
                    }

                    i++;
                }
            }

            if (list1 != null)
            if (list1.Count > 0) rc |= 2;

            if (list2 != null)
            if (list2.Count > 0) rc |= 2;

            return rc;
        }
Example #16
0
        int seek_guid(xmap.IFeature obj, List<int> list, string guid)
        {
            if (list != null)
            for (int i = 0; i < list.Count; i++)
            {
                obj.Get(list[i]);
                if (obj.guid == guid)
                return i;
            }

            return -1;
        }
Example #17
0
        bool move_shape(xmap.IFeature obj1, xmap.IFeature obj2)
        {
            int loc = obj1.Loc;
            if (loc == obj2.Loc) {

                xmap.IPoly mf1 = obj1.mf; mf1.IsWGS = 1;
                xmap.IPoly mf2 = obj2.mf; mf2.IsWGS = 1;

                string key = obj1.guid;
                if (convert.IsString(key))

                if (mf1.PartCount > 0)
                if (mf2.PartCount > 0)

                switch (loc % 100)
                {
                case 1:
                    return move_node(Point2d(mf1, 0, 0),
                                     Point2d(mf2, 0, 0),
                                     key);
                case 2:
                    return move_edge(mf1,mf2,0,key);
                case 3:
                    return move_surface(mf1, mf2, key);
                }
            }

            return false;
        }
Example #18
0
        string surface(xmap.IPoly mf, string id)
        {
            int Nparts = mf.PartCount;
            for (int i = 0; i < Nparts; i++)
            edge(mf,i, part_key(id,i));

            string key = ssTag + id;
            fwriter.WritePropertyName(key);
            fwriter.WriteStartArray();

            write_surface(mf, id);

            fwriter.WriteEndArray();

            return key;
        }
Example #19
0
        bool move_surface(xmap.IPoly mf1, xmap.IPoly mf2, string id)
        {
            bool rc = false;

            int n1 = mf1.PartCount;
            int n2 = mf2.PartCount;
            int n = Math.Max(n1, n2);

            for (int i = 0; i < n; i++)
            {
                string s = part_key(id,i);

                if (i < n2)
                    rc |= move_edge(mf1, mf2, i, s);
                else
                    edge(mf2,i,s);
            }

            if (n1 != n2)
            {
                string key = ssTag + id;
                fwriter.WritePropertyName(key);
                fwriter.WriteStartArray();

                write_surface(mf1, id);
                write_surface(mf2, id);

                fwriter.WriteEndArray();

                rc = true;
            }

            return rc;
        }
Example #20
0
        void write_surface(xmap.IPoly mf, string key)
        {
            fwriter.WriteStartObject();

            fwriter.WritePropertyName("rings");
            fwriter.WriteStartArray();

            for (int i = 0; i < mf.PartCount; i++)
            {
                fwriter.WriteStartObject();

                string s = "forward";
                writeValues("orientation", s);

                if (i == 0) s = "exterior";
                else s = "interior";

                writeValues("exteriorInterior", s);

                writeValues("ref", veTag + part_key(key, i));

                fwriter.WriteEndObject();
            }

            fwriter.WriteEndArray();

            fwriter.WriteEndObject();
        }
Example #21
0
        bool open_map(xmap.Ixmap_auto map, string path)
        {
            map.OpenMap(path);
            map.IsWGS84 = 1;

            if (map.Enabled == 1) return true;
            _message(String.Format("open map '{0}' false.", path));
            return false;
        }
Example #22
0
        void __baseShape(SOAPService.Feature fe,
                         xmap.IFeature obj, int loc)
        {
            if ((loc >= 1) && (loc <= 3))
            {
                int offs = obj.Offset;
                xmap.IPoly mf = obj.mf;
                mf.IsWGS = 1;

                if (mf.PartCount > 0)
                switch (loc)
                {
                    case 1:
                        if (fe.BaseShapePoint == null)
                        {
                            fe.BaseShapePoint = __point(mf);
                            if (fe.BaseShapePoint != null)
                            fe.BaseShapePoint.Metadata = __metadata(offs,1,"");
                        }
                        break;
                    case 2:
                        if (fe.BaseShapePolyline == null)
                        {
                            fe.BaseShapePolyline = __polyline(mf);
                            if (fe.BaseShapePolyline != null)
                            fe.BaseShapePolyline.Metadata = __metadata(offs,1,"");
                        }
                        break;
                    case 3:
                        if (fe.BaseShapePolygon == null)
                        {
                            fe.BaseShapePolygon = __polygon(mf);
                            if (fe.BaseShapePolygon != null)
                            fe.BaseShapePolygon.Metadata = __metadata(offs,1,"");
                        }
                        break;
                }
            }
        }
Example #23
0
        bool PartEquals(xmap.IPoly mf1, xmap.IPoly mf2, int part)
        {
            int n;
            mf1.GetContourCount(part, out n);

            for (int i = 1; i < n - 1; i++)
            {
                bool rc = PointEquals( Point2d(mf1, part, i),
                                       Point2d(mf2, part, i) );
                if (!rc) return false;

            }

            return true;
        }
Example #24
0
 Polygon __polygon(xmap.IPoly mf)
 {
     var pp = new Polygon();
     pp.Type = GeometryType.Polygon;
     pp.Rings = __rings(mf);
     return pp;
 }
Example #25
0
 point2d Point2d(xmap.IPoly mf, int part, int index)
 {
     double x, y; mf.GetPointd(part, index, out x, out y);
     return new point2d(x*RadToDeg, y*RadToDeg);
 }
Example #26
0
        List<Ring> __rings(xmap.IPoly mf)
        {
            var pp = new List<Ring>();

            int parts = mf.PartCount;
            for (int ic = 0; ic < parts; ic++)
            {
                var p = new SOAPService.Ring();
                p.Points = new List<SOAPService.Point>();

                int np; mf.GetContourCount(ic, out np);
                for (int ip = 0; ip < np; ip++)
                {
                    double x, y;
                    mf.GetPointd(ic, ip, out y, out x);
                    x *= RadToDeg; y *= RadToDeg;
                    p.Points.Add(new Point() { X = x, Y = y });

                }

                if (p.Points.Count > 0) pp.Add(p);
            }

            return pp;
        }
Example #27
0
        void add_feature(xmap.Ixmap_auto map, xmap.IFeature obj)
        {
            fGeometry.Clear();
            string s = shape(obj);
            if (convert.IsString(s)) {
                __nextGeometry(s, obj);

                int top;
                int ptr = fmap.get_frst_geometry(obj.Offset, out top);
                while (ptr > 0)
                {
                    fobj1.Get(ptr);
                    s = shape(fobj1);
                    if (convert.IsString(s))
                    __nextGeometry(s, fobj1);

                    ptr = fmap.get_next_geometry(ptr, top);
                }
            }

            fwriter.WritePropertyName(feTag + obj.guid);
            fwriter.WriteStartArray();

            feature(map,obj);

            fwriter.WriteEndArray();

            fadded++;
        }