public void SetGeomAsCenteredRing(List <Network> networks) { /* . . .. * . ... * . . X. . * . . . * .. .. * . . . . . * */ //1.) pick the highest power level observation with the best accuracy //2.) find the lowest power level reading with the best accuracy //calculate the distance, smooth it a bit, and draw a circle that size. //so... we have tons of observations for any given network. for (int i = 0; i < networks.Count; i++) { var net = networks[i]; if (net.Observations.Count == 0) { //TODO: Fix -- cell towers continue; } var closest = PickBestObservation(net, true); var furthest = PickBestObservation(net, false); if ((closest == null) || (furthest == null)) { continue; } var closestPT = closest.GetPoint(); var furthestPT = furthest.GetPoint(); var dist = closestPT.Distance(furthestPT); if (dist > 0.005) { //too big continue; } //draw circle. var fact = new NetTopologySuite.Utilities.GeometricShapeFactory(GeometryFactory.Default); var pt = closestPT; var env = new Envelope(pt.X + dist, pt.X - dist, pt.Y + dist, pt.Y - dist); fact.Envelope = env; fact.Centre = closestPT.Coordinate; fact.NumPoints = 24; fact.Size = dist; net.Geom = fact.CreateCircle(); } }
private static IGeometry CreateCircle(Coordinate origin, double size, int nPts) { var gsf = new NetTopologySuite.Utilities.GeometricShapeFactory(); gsf.Centre = origin; gsf.Size = size; gsf.NumPoints = nPts; var circle = gsf.CreateCircle(); // Polygon gRect = gsf.createRectangle(); // Geometry g = gRect.getExteriorRing(); return circle; }
private static IGeometry CreateCircle(Coordinate origin, double size, int nPts) { var gsf = new NetTopologySuite.Utilities.GeometricShapeFactory(); gsf.Centre = origin; gsf.Size = size; gsf.NumPoints = nPts; var circle = gsf.CreateCircle(); // Polygon gRect = gsf.createRectangle(); // Geometry g = gRect.getExteriorRing(); return(circle); }
public void TestSerializable() { var fact = new GeometryFactory(); var gsf = new NetTopologySuite.Utilities.GeometricShapeFactory(fact) ; gsf.Size = 250; var g = (Geometry)gsf.CreateCircle(); // serialize the object byte[] bytes = null; Assert.DoesNotThrow(() => bytes = SerializationUtility.Serialize(g)); // Assert that there was some serialized content produced Assert.IsNotNull(bytes, "There was no serialized packet produced"); Assert.IsTrue(bytes.Length > 0, "There was no data in the serialized packet produced"); // deserialize and check var gCopy = SerializationUtility.Deserialize<Geometry>(bytes); Assert.IsTrue(gCopy.EqualsExact(g), "The deserialized object does not match the original"); }
public void TestSerializable() { var fact = new GeometryFactory(); var gsf = new NetTopologySuite.Utilities.GeometricShapeFactory(fact); gsf.Size = 250; var g = (Geometry)gsf.CreateCircle(); // serialize the object byte[] bytes = null; Assert.DoesNotThrow(() => bytes = SerializationUtility.Serialize(g)); // Assert that there was some serialized content produced Assert.IsNotNull(bytes, "There was no serialized packet produced"); Assert.IsTrue(bytes.Length > 0, "There was no data in the serialized packet produced"); // deserialize and check var gCopy = SerializationUtility.Deserialize <Geometry>(bytes); Assert.IsTrue(gCopy.EqualsExact(g), "The deserialized object does not match the original"); }
public override bool InitLayer( Mars.Interfaces.Layer.Initialization.TInitData initData, Mars.Interfaces.Layer.RegisterAgent regHandle, Mars.Interfaces.Layer.UnregisterAgent unregHandle) { base.InitLayer(initData, regHandle, unregHandle); this._Register = regHandle; this._Unregister = unregHandle; _DistanceMetric = Mars.Mathematics.SpaceDistanceMetric.Chebyshev; var _gisLayerExist = false; if (!_isDefault && _lowerLeft != null && _upperRight != null) { this._AirTrafficControllerEnvironment = Mars.Components.Environments.GeoHashEnvironment <AirTrafficController> .BuildByBBox(_lowerLeft.Longitude, _lowerLeft.Latitude, _upperRight.Longitude, _upperRight.Latitude); this._AircraftEnvironment = Mars.Components.Environments.GeoHashEnvironment <Aircraft> .BuildByBBox(_lowerLeft.Longitude, _lowerLeft.Latitude, _upperRight.Longitude, _upperRight.Latitude); this._ObserverEnvironment = Mars.Components.Environments.GeoHashEnvironment <Observer> .BuildByBBox(_lowerLeft.Longitude, _lowerLeft.Latitude, _upperRight.Longitude, _upperRight.Latitude); this._PilotEnvironment = Mars.Components.Environments.GeoHashEnvironment <Pilot> .BuildByBBox(_lowerLeft.Longitude, _lowerLeft.Latitude, _upperRight.Longitude, _upperRight.Latitude); this._WeatherEnvironment = Mars.Components.Environments.GeoHashEnvironment <Weather> .BuildByBBox(_lowerLeft.Longitude, _lowerLeft.Latitude, _upperRight.Longitude, _upperRight.Latitude); } else if (_gisLayerExist) { var geometries = new List <GeoAPI.Geometries.IGeometry>(); var _factory = new NetTopologySuite.Utilities.GeometricShapeFactory(); var _feature = new NetTopologySuite.Geometries.GeometryCollection(geometries.ToArray()).EnvelopeInternal; _minLon = _feature.MinX; _minLat = _feature.MinY; _maxLon = _feature.MaxX; _maxLat = _feature.MaxY; this._AirTrafficControllerEnvironment = Mars.Components.Environments.GeoHashEnvironment <AirTrafficController> .BuildByBBox(_feature.MinX, _feature.MinY, _feature.MaxX, _feature.MaxY); this._AircraftEnvironment = Mars.Components.Environments.GeoHashEnvironment <Aircraft> .BuildByBBox(_feature.MinX, _feature.MinY, _feature.MaxX, _feature.MaxY); this._ObserverEnvironment = Mars.Components.Environments.GeoHashEnvironment <Observer> .BuildByBBox(_feature.MinX, _feature.MinY, _feature.MaxX, _feature.MaxY); this._PilotEnvironment = Mars.Components.Environments.GeoHashEnvironment <Pilot> .BuildByBBox(_feature.MinX, _feature.MinY, _feature.MaxX, _feature.MaxY); this._WeatherEnvironment = Mars.Components.Environments.GeoHashEnvironment <Weather> .BuildByBBox(_feature.MinX, _feature.MinY, _feature.MaxX, _feature.MaxY); } else if (_lowerLeft != null && _upperRight != null) { this._AirTrafficControllerEnvironment = Mars.Components.Environments.GeoHashEnvironment <AirTrafficController> .BuildByBBox(_lowerLeft.Longitude, _lowerLeft.Latitude, _upperRight.Longitude, _upperRight.Latitude); this._AircraftEnvironment = Mars.Components.Environments.GeoHashEnvironment <Aircraft> .BuildByBBox(_lowerLeft.Longitude, _lowerLeft.Latitude, _upperRight.Longitude, _upperRight.Latitude); this._ObserverEnvironment = Mars.Components.Environments.GeoHashEnvironment <Observer> .BuildByBBox(_lowerLeft.Longitude, _lowerLeft.Latitude, _upperRight.Longitude, _upperRight.Latitude); this._PilotEnvironment = Mars.Components.Environments.GeoHashEnvironment <Pilot> .BuildByBBox(_lowerLeft.Longitude, _lowerLeft.Latitude, _upperRight.Longitude, _upperRight.Latitude); this._WeatherEnvironment = Mars.Components.Environments.GeoHashEnvironment <Weather> .BuildByBBox(_lowerLeft.Longitude, _lowerLeft.Latitude, _upperRight.Longitude, _upperRight.Latitude); } else { throw new ArgumentException("No environment boundary was used for agent layer 'TestLayer'"); } _AirTrafficControllerAgents = Mars.Components.Services.AgentManager.SpawnAgents <AirTrafficController>( initData.AgentInitConfigs.First(config => config.Type == typeof(AirTrafficController)), regHandle, unregHandle, new System.Collections.Generic.List <Mars.Interfaces.Layer.ILayer> { this }); _AircraftAgents = Mars.Components.Services.AgentManager.SpawnAgents <Aircraft>( initData.AgentInitConfigs.First(config => config.Type == typeof(Aircraft)), regHandle, unregHandle, new System.Collections.Generic.List <Mars.Interfaces.Layer.ILayer> { this }); _ObserverAgents = Mars.Components.Services.AgentManager.SpawnAgents <Observer>( initData.AgentInitConfigs.First(config => config.Type == typeof(Observer)), regHandle, unregHandle, new System.Collections.Generic.List <Mars.Interfaces.Layer.ILayer> { this }); _PilotAgents = Mars.Components.Services.AgentManager.SpawnAgents <Pilot>( initData.AgentInitConfigs.First(config => config.Type == typeof(Pilot)), regHandle, unregHandle, new System.Collections.Generic.List <Mars.Interfaces.Layer.ILayer> { this }); _WeatherAgents = Mars.Components.Services.AgentManager.SpawnAgents <Weather>( initData.AgentInitConfigs.First(config => config.Type == typeof(Weather)), regHandle, unregHandle, new System.Collections.Generic.List <Mars.Interfaces.Layer.ILayer> { this }); return(true); }