private RectangleShape GetBoundingBox(Feature tmpFeature) { if (tmpFeature.GetWellKnownType() == WellKnownType.Point) { PointShape point = (PointShape)tmpFeature.GetShape(); return(point.Buffer(2, map.MapUnit, DistanceUnit.Kilometer).GetBoundingBox()); } else { return(tmpFeature.GetBoundingBox()); } }
protected override void DrawCore(GeoCanvas canvas, Collection <SimpleCandidate> labelsInAllLayers) { PointShape centerPoint = canvas.CurrentWorldExtent.GetCenterPoint(); double currentRingDistance = RingDistance; MultipolygonShape circle = null; // Keep drawing rings until the only barley fit inside the current extent. do { circle = centerPoint.Buffer(currentRingDistance, RingGeography, RingDistanceUnit); canvas.DrawArea(circle, RingAreaStyle.OutlinePen, RingAreaStyle.FillBrush, DrawingLevel.LevelOne); currentRingDistance += RingDistance; } while (canvas.CurrentWorldExtent.Contains(circle)); }
public JsonResult SearchSimilarSites(Map map, GeoCollection <object> args) { string[] searchPointLatLng = args["searchPoint"].ToString().Split(','); PointShape searchPoint = new PointShape(double.Parse(searchPointLatLng[0]), double.Parse(searchPointLatLng[1])); object result = new { status = "2", message = "out of restriction area" }; Feature searchAreaFeature = null; // check if the clicked point is in valid area (Frisco City) FeatureLayer friscoLayer = (FeatureLayer)(map.CustomOverlays["RestrictOverlay"] as LayerOverlay).Layers["RestrictLayer"]; friscoLayer.Open(); if (friscoLayer.QueryTools.GetFeaturesContaining(searchPoint, ReturningColumnsType.NoColumns).Any()) { // Calculate the service area/buffer area and display it on the map if (args["searchMode"].ToString().Equals("serviceArea", StringComparison.InvariantCultureIgnoreCase)) { int drivingTimeInMinutes = Convert.ToInt32(args["driveTime"].ToString(), CultureInfo.InvariantCulture); searchAreaFeature = new Feature(routingEngine.GenerateServiceArea(searchPoint, new TimeSpan(0, drivingTimeInMinutes, 0), 100, GeographyUnit.Meter)); } else { DistanceUnit distanceUnit = args["distanceUnit"].ToString() == "Mile" ? DistanceUnit.Mile : DistanceUnit.Kilometer; double distanceBuffer = Convert.ToDouble(args["distanceBuffer"].ToString(), CultureInfo.InvariantCulture); searchAreaFeature = new Feature(searchPoint.Buffer(distanceBuffer, 40, GeographyUnit.Meter, distanceUnit)); } // Search the Pois in calculated service area and display them on map LayerOverlay poiOverlay = map.CustomOverlays["PoisOverlay"] as LayerOverlay; ShapeFileFeatureLayer poiLayer = (ShapeFileFeatureLayer)(poiOverlay.Layers[args["category"].ToString()]); poiLayer.Open(); Collection <Feature> featuresInServiceArea = poiLayer.QueryTools.GetFeaturesWithin(searchAreaFeature.GetShape(), ReturningColumnsType.AllColumns); List <Feature> filteredQueryFeatures = FilterFeaturesByQueryConfiguration(featuresInServiceArea, args["category"].ToString(), args["subCategory"].ToString().Replace(">~", ">=")); if (filteredQueryFeatures.Any()) { Collection <object> returnedJsonFeatures = new Collection <object>(); foreach (Feature feature in filteredQueryFeatures) { PointShape latlng = feature.GetShape() as PointShape; returnedJsonFeatures.Add(new { name = feature.ColumnValues["NAME"], point = string.Format("{0},{1}", latlng.Y, latlng.X) }); } // Add into plot marker overlay. InMemoryMarkerOverlay drawPointOverlay = map.CustomOverlays["DrawnPointOverlay"] as InMemoryMarkerOverlay; drawPointOverlay.FeatureSource.Clear(); drawPointOverlay.FeatureSource.BeginTransaction(); drawPointOverlay.FeatureSource.AddFeature(new Feature(searchPoint)); drawPointOverlay.FeatureSource.CommitTransaction(); // Add into markerOvelray. AddMarkers(filteredQueryFeatures, map); Feature wgs84Feature = new Feature(searchAreaFeature.GetShape()); // Add into queried overlay. LayerOverlay queriedOverlay = map.CustomOverlays["QueriedOverlay"] as LayerOverlay; InMemoryFeatureLayer serviceAreaLayer = (queriedOverlay.Layers["serviceArea"] as InMemoryFeatureLayer); serviceAreaLayer.Open(); serviceAreaLayer.InternalFeatures.Clear(); serviceAreaLayer.InternalFeatures.Add(wgs84Feature); result = new { status = "0", message = "has features", features = returnedJsonFeatures }; } else { result = new { status = "1", message = "without features" }; } } // return the search poi feature information to the client. return(Json(result)); }