Exemplo n.º 1
0
 public static System.Data.Entity.Spatial.DbGeometry UnionAggregate(
     IEnumerable<System.Data.Entity.Spatial.DbGeometry> dbGeometrys)
 {
     var wktReader = new WKTReader();
     var geometries = dbGeometrys.Select(x => wktReader.Read(x.WellKnownValue.WellKnownText)).ToArray();
     var collection = new GeometryCollection(geometries);
     var wktWriter = new WKTWriter();
     return System.Data.Entity.Spatial.DbGeometry.FromText(wktWriter.Write(collection));
 }
Exemplo n.º 2
0
        public static System.Data.Entity.Spatial.DbGeometry UnionAggregate(
            IEnumerable <System.Data.Entity.Spatial.DbGeometry> dbGeometrys)
        {
            var wktReader  = new WKTReader();
            var geometries = dbGeometrys.Select(x => wktReader.Read(x.WellKnownValue.WellKnownText)).ToArray();
            var collection = new GeometryCollection(geometries);
            var wktWriter  = new WKTWriter();

            return(System.Data.Entity.Spatial.DbGeometry.FromText(wktWriter.Write(collection)));
        }
Exemplo n.º 3
0
        private static IGeometryCollection ReadGeometryCollection(JsonTextReader jreader)
        {
            if (jreader == null)
            {
                throw new ArgumentNullException("reader", "A valid JSON reader object is required.");
            }

            IGeometryCollection geometries = null;

            if (jreader.TokenClass == JsonTokenClass.Array)
            {
                jreader.ReadToken(JsonTokenClass.Array);
                List <IGeometry> list = new List <IGeometry>();
                while (jreader.TokenClass == JsonTokenClass.Object)
                {
                    IGeometry geometry = Read(jreader);
                    list.Add(geometry);
                }
                jreader.ReadToken(JsonTokenClass.EndArray);
                geometries = new NetTopologySuite.Geometries.GeometryCollection(list.ToArray());
            }
            return(geometries);
        }
Exemplo n.º 4
0
        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);
        }