${iServerJava6R_ServerType_ServerRoute_Tile}

${iServerJava6R_ServerType_ServerRoute_Description}

Inheritance: ServerGeometry
コード例 #1
0
        /// <summary>${iServerJava6R_ServerType_method_FromJson_D}</summary>
        /// <returns>${iServerJava6R_ServerType_method_FromJson_return}</returns>
        /// <param name="json">${iServerJava6R_ServerType_method_FromJson_param_jsonObject}</param>
        public static ServerGeometry FromJson(JsonObject json)
        {
            if (json == null)
            {
                return null;
            }
            ServerGeometryType type;
            bool isSuccess = Enum.TryParse<ServerGeometryType>((string)json["type"], true, out type);

            ServerGeometry geometry;
            if (type == ServerGeometryType.LINEM)
            {
                geometry = new ServerRoute();
                ((ServerRoute)geometry).Length = (double)json["length"];
                ((ServerRoute)geometry).MaxM = (double)json["maxM"];
                ((ServerRoute)geometry).MinM = (double)json["minM"];
            }
            else
            {
                geometry = new ServerGeometry();
            }

            if (isSuccess)
            {
                geometry.Type = type;
            }
            else
            {
                return geometry;
            }
            geometry.ID = (int)json["id"];
            geometry.Style = ServerStyle.FromJson((JsonObject)json["style"]);

            JsonArray parts = (JsonArray)json["parts"];
            if (parts != null && parts.Count > 0)
            {
                geometry.Parts = new List<int>();
                for (int i = 0; i < parts.Count; i++)
                {
                    geometry.Parts.Add((int)parts[i]);
                }
            }

            JsonArray point2Ds = (JsonArray)json["points"];
            if (point2Ds != null && point2Ds.Count > 0)
            {
                geometry.Points = new Point2DCollection();
                for (int i = 0; i < point2Ds.Count; i++)
                {
                    Point2D point = JsonHelper.ToPoint2D((JsonObject)point2Ds[i]);
                    if (type == ServerGeometryType.LINEM)
                    {
                        if (point != Point2D.Empty && ((JsonObject)point2Ds[i]).ContainsKey("measure"))
                        {
                            point.Tag = (double)(((JsonObject)point2Ds[i])["measure"]);
                        }
                    }
                    geometry.Points.Add(point);
                }
            }

            return geometry;
        }
コード例 #2
0
        /// <summary>${iServerJava6R_Bridge_method_GeometryToServerGeometry_D}</summary>
        /// <returns>${iServerJava6R_Bridge_method_GeometryToServerGeometry_return}</returns>
        /// <param name="geo">${iServerJava6R_Bridge_method_GeometryToServerGeometry_param_geo}</param>
        public static ServerGeometry ToServerGeometry(this SuperMap.Web.Core.Geometry geo)
        {
            if (geo == null)
            {
                return null;
            }

            ServerGeometry sg = new ServerGeometry();

            Point2DCollection list = new Point2DCollection();
            List<int> parts = new List<int>();

            if (geo is GeoRegion)
            {
                for (int i = 0; i < ((GeoRegion)geo).Parts.Count; i++)
                {
                    for (int j = 0; j < ((GeoRegion)geo).Parts[i].Count; j++)
                    {
                        list.Add(new Point2D(((GeoRegion)geo).Parts[i][j].X, ((GeoRegion)geo).Parts[i][j].Y));
                    }
                    parts.Add(((GeoRegion)geo).Parts[i].Count);
                }
                sg.Type = ServerGeometryType.REGION;
            }

            if (geo is GeoCircle)
            {
                for (int i = 0; i < ((GeoCircle)geo).Parts.Count; i++)
                {
                    for (int j = 0; j < ((GeoCircle)geo).Parts[i].Count; j++)
                    {
                        list.Add(new Point2D(((GeoCircle)geo).Parts[i][j].X, ((GeoCircle)geo).Parts[i][j].Y));
                    }
                    parts.Add(((GeoCircle)geo).Parts[i].Count);
                }
                sg.Type = ServerGeometryType.REGION;
            }

            if (geo is GeoLine)
            {
                if (geo is Route)
                {
                    sg = new ServerRoute();
                }
                for (int i = 0; i < ((GeoLine)geo).Parts.Count; i++)
                {
                    for (int j = 0; j < ((GeoLine)geo).Parts[i].Count; j++)
                    {
                        Point2D point = new Point2D(((GeoLine)geo).Parts[i][j].X, ((GeoLine)geo).Parts[i][j].Y);
                        if (geo is Route)
                        {
                            point.Tag = ((Route)geo).Parts[i][j].Tag;
                        }
                        list.Add(point);
                    }
                    parts.Add(((GeoLine)geo).Parts[i].Count);
                }
                sg.Type = ServerGeometryType.LINE;
                if (geo is Route)
                {
                    sg.Type = ServerGeometryType.LINEM;
                    ((ServerRoute)sg).Length = ((Route)geo).Length;
                    ((ServerRoute)sg).MaxM = ((Route)geo).MaxM;
                    ((ServerRoute)sg).MinM = ((Route)geo).MinM;
                }

            }

            if (geo is GeoPoint)
            {
                list.Add(new Point2D(((GeoPoint)geo).X, ((GeoPoint)geo).Y));
                parts.Add(list.Count);
                sg.Type = ServerGeometryType.POINT;
            }

            sg.Points = list;
            sg.Parts = parts;
            sg.ID = -1;
            return sg;
        }