Esempio n. 1
0
        public ImageMapLine(SharpMap.Geometries.Geometry geom, SharpMap.Map map, ImageMapStyle mapStyle)
            : base(geom, map)
        {
            PointF[] transLine = (geom as LineString).TransformToImage(map);
            map.MapTransform.TransformPoints(transLine);

            List <PointF> tempPoly = new List <PointF>();

            for (int i = 0; i < transLine.Length; i++)
            {
                PointF p = transLine[i];
                tempPoly.Add(new System.Drawing.PointF((p.X - mapStyle.Line.BufferWidth), (p.Y + mapStyle.Line.BufferWidth)));
                tempPoly.Add(new System.Drawing.PointF((p.X + mapStyle.Line.BufferWidth), (p.Y + mapStyle.Line.BufferWidth)));
            }

            for (int i = transLine.Length - 1; i > -1; i--)
            {
                PointF p = transLine[i];
                tempPoly.Add(new System.Drawing.PointF((p.X - mapStyle.Line.BufferWidth), (p.Y - mapStyle.Line.BufferWidth)));
                tempPoly.Add(new System.Drawing.PointF((p.X + mapStyle.Line.BufferWidth), (p.Y - mapStyle.Line.BufferWidth)));
            }

            if (!tempPoly[0].Equals(tempPoly[tempPoly.Count - 1]))
            {
                tempPoly.Add(tempPoly[0]);
            }

            PointF[] tp = tempPoly.ToArray();
            tp = ImageMapUtilities.ClipPolygon(tp, map.Size.Width, map.Size.Height);
            foreach (PointF pf in tp)
            {
                coords.Add(pf);
            }
        }
Esempio n. 2
0
        public ImageMapPoint(SharpMap.Geometries.Geometry geom, SharpMap.Map map, ImageMapStyle mapStyle)
            : base(geom, map)
        {
            this.Radius = mapStyle.Point.Radius;

            SharpMap.Geometries.Point P = geom as SharpMap.Geometries.Point;
            PointF pf = map.WorldToImage(P);

            map.MapTransform.TransformPoints(new PointF[] { pf });
            center = new System.Drawing.Point((int)pf.X, (int)pf.Y);
        }
Esempio n. 3
0
        private void CreateFeatureElements(List <ImageMapFeatureElement> targetList, ILayer lyr, Map map)
        {
            if (map.Center == null)
            {
                throw (new ApplicationException("Cannot render map. View center not specified"));
            }



            IDataLayer dataLayer = lyr as IDataLayer;

            if (dataLayer == null)
            {
                return;
            }

            IProvider dataSource = dataLayer.DataSource;

            if (this.ImageMapStyle != null || this._themeProvider != null)
            {
                FeatureDataSet ds = new FeatureDataSet();

                dataSource.Open();
                dataSource.ExecuteIntersectionQuery(map.Envelope, ds);
                dataSource.Close();

                if (ds.Tables.Count > 0)
                {
                    FeatureDataTable features = ds.Tables[0];

                    for (int k = 0; k < features.Count; k++)
                    {
                        FeatureDataRow fdr = features[k];

                        ImageMapStyle useStyle =
                            this._themeProvider != null?this._themeProvider(lyr, fdr) : this.ImageMapStyle;

                        if (useStyle == null ||
                            !useStyle.Enabled ||
                            map.Zoom < useStyle.MinVisible ||
                            map.Zoom > useStyle.MaxVisible)
                        {
                            continue;
                        }

                        AddFeatureElement(targetList, map, lyr, fdr.Geometry, fdr, useStyle);
                    }
                }
            }
        }
Esempio n. 4
0
        public static ImageMapFeatureElement CreateImageMapElement(SharpMap.Geometries.Geometry geom, SharpMap.Map map, ImageMapStyle mapStyle)
        {
            if (!mapStyle.Enabled)
            {
                return(null);
            }

            if (geom as Polygon != null &&
                mapStyle.Polygon.Enabled &&
                map.Zoom > mapStyle.Polygon.MinVisible &&
                map.Zoom < mapStyle.Polygon.MaxVisible)
            {
                return(new ImageMapPolygon(geom, map));
            }
            else if (geom as LineString != null &&
                     mapStyle.Line.Enabled &&
                     map.Zoom > mapStyle.Line.MinVisible &&
                     map.Zoom < mapStyle.Line.MaxVisible)
            {
                return(new ImageMapLine(geom, map, mapStyle));
            }
            else if (geom as SharpMap.Geometries.Point != null &&
                     mapStyle.Point.Enabled &&
                     map.Zoom > mapStyle.Point.MinVisible &&
                     map.Zoom < mapStyle.Point.MaxVisible)
            {
                return(new ImageMapPoint(geom, map, mapStyle));
            }
            return(null);
        }
Esempio n. 5
0
 private void AddFeatureElement(List <ImageMapFeatureElement> storage, Map map, ILayer lyr, Geometry geometry, FeatureDataRow fdr, ImageMapStyle useStyle)
 {
     if (geometry as GeometryCollection != null)
     {
         foreach (Geometry geom in geometry as GeometryCollection)
         {
             AddFeatureElement(storage, map, lyr, geom, fdr, useStyle);
         }
     }
     else
     {
         ImageMapFeatureElement imel = ImageMapFeatureElement.CreateImageMapElement(geometry, map, useStyle);
         if (imel != null)
         {
             foreach (KeyValuePair <string, Func <ILayer, FeatureDataRow, string> > attrAccessor in AttributeProviders)
             {
                 string attrVal = attrAccessor.Value(lyr, fdr);
                 if (!string.IsNullOrEmpty(attrVal))
                 {
                     imel.AddAttribute(attrAccessor.Key, attrVal);
                 }
             }
             storage.Add(imel);
         }
     }
 }