예제 #1
0
        public static Map Spherical()
        {
            ICoordinateTransformation transformation = ProjHelper.LatLonToGoogle();
            HttpContext context = HttpContext.Current;
            Map         map     = new Map(new Size(1, 1));

            IDictionary <string, LayerData> dict = Nyc;

            foreach (string layer in dict.Keys)
            {
                string format = String.Format("~/App_Data/{0}", layer);
                string path   = context.Server.MapPath(format);
                if (!File.Exists(path))
                {
                    throw new FileNotFoundException("file not found", path);
                }

                string      name   = Path.GetFileNameWithoutExtension(layer);
                LayerData   data   = dict[layer];
                ShapeFile   source = new ShapeFile(path, true);
                VectorLayer item   = new VectorLayer(name, source)
                {
                    SRID       = 4326,
                    TargetSRID = 900913,
                    CoordinateTransformation = transformation,
                    Style         = (VectorStyle)data.Style,
                    SmoothingMode = Smoothing.AntiAlias
                };
                map.Layers.Add(item);
            }
            return(map);
        }
예제 #2
0
        private static VectorLayer CreateLayer(string connstr, string name, VectorStyle style)
        {
            if (connstr == null)
            {
                throw new ArgumentNullException("connstr");
            }
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }


            SqlServer2008 source = new SqlServer2008(connstr, name, "geom", "ID")
            {
                ValidateGeometries = true
            };
            ICoordinateTransformation transformation = ProjHelper.LatLonToGoogle();
            VectorLayer item = new VectorLayer(name, source)
            {
                SRID       = 4326,
                TargetSRID = 900913,
                CoordinateTransformation = transformation,
                Style         = style,
                SmoothingMode = SmoothingMode.AntiAlias,
            };

            return(item);
        }
예제 #3
0
        private static VectorLayer CreateLayer(string connstr, string name, VectorStyle style)
        {
            if (connstr == null)
            {
                throw new ArgumentNullException("connstr");
            }
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }


            var source = new SqlServer2008(connstr, name, "geom", "ID",
                                           SqlServerSpatialObjectType.Geometry, 0, SqlServer2008ExtentsMode.QueryIndividualFeatures)
            {
                ValidateGeometries = true
            };
            var transformation = ProjHelper.LatLonToGoogle();
            var item           = new VectorLayer(name, source)
            {
                SRID       = 4326,
                TargetSRID = 900913,
                CoordinateTransformation = transformation,
                Style         = style,
                SmoothingMode = SmoothingMode.AntiAlias,
            };

            return(item);
        }