Hi ThinkGeo Team
I have managed to draw polygons based on the GPS coordinates collected using my GPS device. Now when I attempt to query to verify if the newly added polygon feature overlaps with the existing polygons, nothing appears although I am quite sure that the newly added polygon will overlap with the existing polygons. Below is part of my code that performs feature querying. Can you please correct me on that code?
FeatureSourceColumn column = new FeatureSourceColumn("Temp", "string", 50);
Collection<FeatureSourceColumn> columns = new Collection<FeatureSourceColumn>();
columns.Add(column);
InMemoryFeatureLayer inMemoryLayer = new InMemoryFeatureLayer(columns, new Collection<Feature>());
GoogleOverlay google = new GoogleOverlay("Google Map");
google.GoogleMapType = GoogleMapType.Normal;
google.JavaScriptLibraryUri = new Uri(ConfigurationManager.AppSettings["GoogleUri"]);
Map1.CustomOverlays.Add(google);
ManagedProj4Projection proj = new ManagedProj4Projection();
proj.InternalProjectionParameters = ManagedProj4Projection.GetEpsgParameters(4326);
proj.ExternalProjectionParameters = ManagedProj4Projection.GetGoogleMapParameters();
inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.SymbolPen = new GeoPen(GeoColor.FromArgb(255, GeoColor.StandardColors.Green), 8);
inMemoryLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
inMemoryLayer.FeatureSource.Projection = proj;
double Latitude_Ring = 0;
double Longitude_Ring = 0;
Int64 PlotID = 0;
Collection<Vertex> points_Feature = new Collection<Vertex>();
Collection<Vertex> points = new Collection<Vertex>();
// Looping through my data table for the existing features
for (int i = 0; i < rw.Length; i++)
{
double Latitude = double.Parse(rw[i]["Longitude"].ToString());
double Longitude = double.Parse(rw[i]["Latitude"].ToString());
Vertex vertex = new Vertex(Longitude, Latitude);
points.Add(vertex);
}
RingShape ring = new RingShape(points);
PolygonShape polygon = new PolygonShape(ring);
Feature feature_poly = new Feature(polygon);
feature_poly.ColumnValues.Add(key, "PolygonShape");
inMemoryLayer.InternalFeatures.Add(Polygon, feature_poly);
// Looping through my data table for the new feature
for (int i_plot = 0; i_plot < rw_plot.Length; i_plot++)
{
Latitude_Ring = double.Parse(rw_plot[i_plot]["Longitude"].ToString());
Longitude_Ring = double.Parse(rw_plot[i_plot]["Latitude"].ToString());
Vertex vertex_Feature = new Vertex(Latitude_Ring, Longitude_Ring);
points_Feature.Add(vertex_Feature);
}
RingShape ring_Feature = new RingShape(points_Feature);
PolygonShape polygon_Feature = new PolygonShape(ring_Feature);
Feature feature_Feature = new Feature(polygon_Feature);
Collection<Feature> spatialQueryResults;
inMemoryLayer.Open();
spatialQueryResults = inMemoryLayer.QueryTools.GetFeaturesOverlapping(feature_Feature, new string[0]);
InMemoryFeatureLayer spatialQueryResultLayer = new InMemoryFeatureLayer(columns, new Collection<Feature>());
spatialQueryResultLayer.InternalFeatures.Clear();
foreach (Feature feature in spatialQueryResults)
{
spatialQueryResultLayer.InternalFeatures.Add(feature.Id, feature);
}
TextStyle textStyle = new TextStyle("Temp", new GeoFont("Arial", 7), new GeoSolidBrush(GeoColor.SimpleColors.Red));
spatialQueryResultLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = textStyle;
spatialQueryResultLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.FromArgb(100, GeoColor.StandardColors.RoyalBlue);
spatialQueryResultLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.StandardColors.Blue;
spatialQueryResultLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.OuterPen = new GeoPen(GeoColor.FromArgb(200, GeoColor.StandardColors.Red), 5);
spatialQueryResultLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.SymbolPen = new GeoPen(GeoColor.FromArgb(255, GeoColor.StandardColors.Green), 8);
spatialQueryResultLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
LayerOverlay dynamicOverlay11 = new LayerOverlay();
dynamicOverlay11.IsBaseOverlay = false;
dynamicOverlay11.Name = "All Property";
dynamicOverlay11.TileType = TileType.SingleTile;
dynamicOverlay11.Layers.Add("DynamicLayer11", spatialQueryResultLayer);
Map1.CustomOverlays.Add(dynamicOverlay11);
Map1.CurrentExtent = inMemoryLayer.GetBoundingBox();
Best Regards,
Vincent.