/// <summary> /// Returns the data associated with all the geometries that are intersected by 'geom' /// /// Note! The table added should be named according to the LayerName! /// </summary> /// <param name="geometry">Geometry to intersect with</param> /// <param name="ds">FeatureDataSet to fill data into</param> public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataSet ds) { if (CoordinateTransformation != null) { #if !DotSpatialProjection geometry = GeometryTransform.TransformGeometry(geometry, CoordinateTransformation.MathTransform.Inverse(), geometry.Factory); #else geometry = GeometryTransform.TransformGeometry(geometry, CoordinateTransformation.Target, CoordinateTransformation.Source, CoordinateTransformation.TargetFactory); #endif } DataSource.ExecuteIntersectionQuery(geometry, ds); if (ds.Tables.Count > 0) { ds.Tables[0].TableName = LayerName; } }
/// <summary> /// Returns the data associated with all the geometries that are intersected by 'geom' /// /// Note! The table added should be named according to the LayerName! /// </summary> /// <param name="box">Bounding box to intersect with</param> /// <param name="ds">FeatureDataSet to fill data into</param> public void ExecuteIntersectionQuery(Envelope box, FeatureDataSet ds) { if (CoordinateTransformation != null) { #if !DotSpatialProjection box = GeometryTransform.TransformBox(box, CoordinateTransformation.MathTransform.Inverse()); #else box = GeometryTransform.TransformBox(box, CoordinateTransformation.Target, CoordinateTransformation.Source); #endif } DataSource.ExecuteIntersectionQuery(box, ds); if (ds.Tables.Count > 0) { ds.Tables[0].TableName = LayerName; } }
private void FormMovingObjectOverTileLayer_Load(object sender, EventArgs e) { //Lisbon... #if DotSpatialProjections var mathTransform = LayerTools.Wgs84toGoogleMercator; var geom = GeometryTransform.TransformBox( new Envelope(-9.205626, -9.123736, 38.690993, 38.740837), mathTransform.Source, mathTransform.Target); #else var mathTransform = LayerTools.Wgs84toGoogleMercator.MathTransform; GeoAPI.Geometries.Envelope geom = GeometryTransform.TransformBox( new Envelope(-9.205626, -9.123736, 38.690993, 38.740837), mathTransform); #endif //Google Background TileAsyncLayer layer2 = new TileAsyncLayer(new OsmTileSource(), "TileLayer - OSM"); this.mapBox1.Map.BackgroundLayer.Add(layer2); var gf = new GeometryFactory(new PrecisionModel(), 3857); //Adds a static layer var staticLayer = new VectorLayer("Fixed Marker"); //position = geom.GetCentroid(); var aux = new List <IGeometry>(); aux.Add(gf.CreatePoint(geom.Centre)); staticLayer.Style.Symbol = Resources.PumpSmall; var geoProviderFixed = new SharpMap.Data.Providers.FeatureProvider(aux); staticLayer.DataSource = geoProviderFixed; this.mapBox1.Map.Layers.Add(staticLayer); //Adds a moving variable layer VectorLayer pushPinLayer = new VectorLayer("PushPins"); position = geom.Centre; geos.Add(gf.CreatePoint(position)); pushPinLayer.Style.Symbol = Resources.OutfallSmall; var geoProvider = new SharpMap.Data.Providers.FeatureProvider(geos); pushPinLayer.DataSource = geoProvider; this.mapBox1.Map.VariableLayers.Add(pushPinLayer); this.mapBox1.Map.ZoomToBox(geom); this.mapBox1.Refresh(); }
private void FormMovingObjectOverTileLayer_Load(object sender, EventArgs e) { //Lisbon... #if DotSpatialProjections var mathTransform = LayerTools.Wgs84toGoogleMercator; SharpMap.Geometries.BoundingBox geom = GeometryTransform.TransformBox( new SharpMap.Geometries.BoundingBox(-9.205626, 38.690993, -9.123736, 38.740837), mathTransform.Source, mathTransform.Target); #else var mathTransform = LayerTools.Wgs84toGoogleMercator.MathTransform; SharpMap.Geometries.BoundingBox geom = GeometryTransform.TransformBox( new SharpMap.Geometries.BoundingBox(-9.205626, 38.690993, -9.123736, 38.740837), mathTransform); #endif //Google Background TileAsyncLayer bingLayer = new TileAsyncLayer(new BingTileSource(BingRequest.UrlBing, "", BingMapType.Roads), "TileLayer - Bing"); this.mapBox1.Map.BackgroundLayer.Add(bingLayer); //Adds a static layer VectorLayer staticLayer = new VectorLayer("Fixed Marker"); //position = geom.GetCentroid(); List <SharpMap.Geometries.Geometry> aux = new List <SharpMap.Geometries.Geometry>(); aux.Add(geom.GetCentroid()); staticLayer.Style.Symbol = Resources.PumpSmall; SharpMap.Data.Providers.GeometryProvider geoProviderFixed = new SharpMap.Data.Providers.GeometryProvider(aux); staticLayer.DataSource = geoProviderFixed; this.mapBox1.Map.Layers.Add(staticLayer); //Adds a moving variable layer VectorLayer pushPinLayer = new VectorLayer("PushPins"); position = geom.GetCentroid(); geos.Add(position); pushPinLayer.Style.Symbol = Resources.OutfallSmall; SharpMap.Data.Providers.GeometryProvider geoProvider = new SharpMap.Data.Providers.GeometryProvider(geos); pushPinLayer.DataSource = geoProvider; this.mapBox1.Map.VariableLayers.Add(pushPinLayer); this.mapBox1.Map.ZoomToBox(geom); this.mapBox1.Refresh(); }
private void FormDemoDrawGeometries_Load(object sender, EventArgs e) { //this.mapBox1.Map = ShapefileSample.InitializeMap(0); //Google Background TileAsyncLayer bingLayer = new TileAsyncLayer(new BingTileSource(BingRequest.UrlBing, "", BingMapType.Roads), "TileLayer - Bing"); this.mapBox1.Map.BackgroundLayer.Add(bingLayer); SharpMap.Layers.VectorLayer vl = new VectorLayer("My Geometries"); geoProvider = new SharpMap.Data.Providers.GeometryProvider(new List <SharpMap.Geometries.Geometry>()); vl.DataSource = geoProvider; this.mapBox1.Map.Layers.Add(vl); /* * SharpMap.Geometries.BoundingBox geom = * ProjNet.CoordinateSystems.Transformations.GeometryTransform.TransformBox( * new SharpMap.Geometries.BoundingBox(-9.205626, 38.690993, -9.123736, 38.740837), * LayerTools.Wgs84toGoogleMercator.MathTransform); */ #if DotSpatialProjections var mathTransform = LayerTools.Wgs84toGoogleMercator; SharpMap.Geometries.BoundingBox geom = GeometryTransform.TransformBox( new SharpMap.Geometries.BoundingBox(-9.205626, 38.690993, -9.123736, 38.740837), mathTransform.Source, mathTransform.Target); #else var mathTransform = LayerTools.Wgs84toGoogleMercator.MathTransform; SharpMap.Geometries.BoundingBox geom = GeometryTransform.TransformBox( new SharpMap.Geometries.BoundingBox(-9.205626, 38.690993, -9.123736, 38.740837), mathTransform); #endif this.mapBox1.Map.ZoomToExtents(); //(geom); this.mapBox1.Refresh(); this.mapBox1.GeometryDefined += new SharpMap.Forms.MapBox.GeometryDefinedHandler(mapBox1_GeometryDefined); this.mapBox1.ActiveToolChanged += new SharpMap.Forms.MapBox.ActiveToolChangedHandler(mapBox1_ActiveToolChanged); this.mapBox1.MouseMove += new SharpMap.Forms.MapBox.MouseEventHandler(mapBox1_MouseMove); }
private void DrawPoints(Map map, IEnumerable <DataRow> features, Bitmap dot, Bitmap image) { var size = new Size(dot.Width, dot.Height); foreach (FeatureDataRow row in features) { var heatValue = HeatValueComputer(row); if (heatValue <= 0) { continue; } if (heatValue >= 1f) { heatValue = 1; } var c = row.Geometry.PointOnSurface.Coordinate; if (CoordinateTransformation != null) { #if !DotSpatialProjection c = GeometryTransform.TransformCoordinate(c, CoordinateTransformation.MathTransform); #else c = GeometryTransform.TransformCoordinate(c, CoordinateTransformation.Source, CoordinateTransformation.Target); #endif } var posF = map.WorldToImage(c); var pos = Point.Round(posF); //var pos = Point.Round(PointF.Subtract(posF, halfSize)); using (var tmpDot = ApplyHeatValueToImage(dot, heatValue)) { ImageBlender.BlendImages(image, pos.X, pos.Y, size.Width, size.Height, tmpDot, 0, 0, BlendOperation.BlendMultiply); } } }