Esempio n. 1
0
 public virtual void Finish(FeatureCollection collection)
 {
     _numberOfPaths       = collection.GetFeature <IEngineFeature>().NumberOfPaths + 1;
     _numberOfDimensions  = collection.GetFeature <IPathMappingFeature>().NumberOfDimensions;
     _numberOfDimensions *= collection.GetFeature <ITimeStepsFeature>().TimeStepCount;
     InitDimensions();
 }
Esempio n. 2
0
 public void Finish(FeatureCollection collection)
 {
     _numberOfPaths = collection.GetFeature <IEngineFeature>().NumberOfPaths + 1;
     _factors       = collection.GetFeature <IPathMappingFeature>().NumberOfDimensions;
     _timesteps     = collection.GetFeature <ITimeStepsFeature>().TimeStepCount;
     Init1stDimension();
     SetupShifts();
 }
Esempio n. 3
0
        public void Finish(FeatureCollection collection)
        {
            var dims = collection.GetFeature <IPathMappingFeature>();

            _assetIndex = dims.GetDimension(_assetName);

            var dates = collection.GetFeature <ITimeStepsFeature>();

            _expiryIndex = dates.GetDateIndex(_expiry);
            _isComplete  = true;
        }
Esempio n. 4
0
        public void SetupFeatures(FeatureCollection pathProcessFeaturesCollection)
        {
            var mappingFeature = pathProcessFeaturesCollection.GetFeature <IPathMappingFeature>();

            _factorIndex = mappingFeature.AddDimension(_name);

            _timesteps = pathProcessFeaturesCollection.GetFeature <ITimeStepsFeature>();
            var stepSize = (_expiryDate - _startDate).TotalDays / _numberOfSteps;

            for (var i = 0; i < _numberOfSteps - 1; i++)
            {
                _timesteps.AddDate(_startDate.AddDays(i * stepSize));
            }
            _timesteps.AddDate(_expiryDate);
        }
Esempio n. 5
0
        public void Finish(FeatureCollection collection)
        {
            var dims = collection.GetFeature <IPathMappingFeature>();

            _assetIndex = dims.GetDimension(_assetName);

            var dates = collection.GetFeature <ITimeStepsFeature>();

            _dateIndexes = new int[_asianDates.Count];
            for (var i = 0; i < _asianDates.Count; i++)
            {
                _dateIndexes[i] = dates.GetDateIndex(_asianDates[i]);
            }
            _isComplete = true;
        }
Esempio n. 6
0
            public void SetupFeatures(FeatureCollection pathProcessFeaturesCollection)
            {
                var mappingFeature = pathProcessFeaturesCollection.GetFeature <IPathMappingFeature>();

                for (var i = 0; i < _numberOfDimensions; i++)
                {
                    mappingFeature.AddDimension($"{_name}-{i}");
                }
                var dates = pathProcessFeaturesCollection.GetFeature <ITimeStepsFeature>();

                for (var i = 0; i < _timesteps; i++)
                {
                    dates.AddDate(DateTime.Now.Date.AddDays(i));
                }
            }
Esempio n. 7
0
        public void Finish(FeatureCollection collection)
        {
            var dims = collection.GetFeature <IPathMappingFeature>();

            _assetIndex  = dims.GetDimension(_assetName);
            _outputIndex = dims.GetDimension(_name);
        }
Esempio n. 8
0
        public void Finish(FeatureCollection collection)
        {
            var dims = collection.GetFeature <IPathMappingFeature>();

            _assetIndex1 = dims.GetDimension(_assetName1);
            _assetIndex2 = dims.GetDimension(_assetName2);

            _isComplete = true;
        }
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            AddOnlineBaseLayer(CartoBaseMapStyle.CartoBasemapStylePositron);

            // read json from assets and add to map
            string json;

            using (System.IO.StreamReader sr = new System.IO.StreamReader(Assets.Open("cities15000.geojson")))
            {
                json = sr.ReadToEnd();
            }

            // Initialize a local vector data source
            LocalVectorDataSource source = new LocalVectorDataSource(BaseProjection);

            // Initialize a vector layer with the previous data source
            ClusteredVectorLayer layer = new ClusteredVectorLayer(source, new MyClusterElementBuilder(this));

            layer.MinimumClusterDistance = 50;

            new System.Threading.Thread((obj) =>
            {
                // Create a basic style, as the ClusterElementBuilder will set the real style
                var markerStyleBuilder  = new MarkerStyleBuilder();
                markerStyleBuilder.Size = 14;
                MarkerStyle style       = markerStyleBuilder.BuildStyle();

                // Read GeoJSON, parse it using SDK GeoJSON parser
                GeoJSONGeometryReader reader = new GeoJSONGeometryReader();

                // Set target projection to base (mercator)
                reader.TargetProjection = BaseProjection;
                Alert("Starting load from .geojson");

                // Read features from local asset
                FeatureCollection features = reader.ReadFeatureCollection(json);
                Alert("Finished load from .geojson");

                VectorElementVector elements = new VectorElementVector();

                for (int i = 0; i < features.FeatureCount; i++)
                {
                    // This data set features point geometry,
                    // however, it can also be LineGeometry or PolygonGeometry
                    PointGeometry geometry = (PointGeometry)features.GetFeature(i).Geometry;
                    elements.Add(new Marker(geometry, style));
                }

                source.AddAll(elements);
                Alert("Clustering started. Please wait...");

                // Add the clustered vector layer to the map
                MapView.Layers.Add(layer);
            }).Start();
        }
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            // Add default base layer
            AddOnlineBaseLayer(CartoBaseMapStyle.CartoBasemapStylePositron);

            // Initialize a local vector data source
            LocalVectorDataSource source = new LocalVectorDataSource(BaseProjection);

            // Initialize a vector layer with the previous data source
            var layer = new ClusteredVectorLayer(source, new MyClusterElementBuilder());

            // Default is 100. A good value depends on data
            layer.MinimumClusterDistance = 50;

            // read json from assets and add to map
            string json = System.IO.File.ReadAllText(AssetUtils.CalculateResourcePath("cities15000.geojson"));

            // Create a basic style, as the ClusterElementBuilder will set the real style
            var markerStyleBuilder = new MarkerStyleBuilder();

            markerStyleBuilder.Size = 14;
            MarkerStyle style = markerStyleBuilder.BuildStyle();

            // Read GeoJSON, parse it using SDK GeoJSON parser
            GeoJSONGeometryReader reader = new GeoJSONGeometryReader();

            // Set target projection to base (mercator)
            reader.TargetProjection = BaseProjection;

            // Read features from local asset
            FeatureCollection features = reader.ReadFeatureCollection(json);

            VectorElementVector elements = new VectorElementVector();

            for (int i = 0; i < features.FeatureCount; i++)
            {
                // This data set features point geometry,
                // however, it can also be LineGeometry or PolygonGeometry
                PointGeometry geometry = (PointGeometry)features.GetFeature(i).Geometry;
                elements.Add(new Marker(geometry, style));
            }

            // Add the clustered vector layer to the map
            source.AddAll(elements);

            MapView.Layers.Add(layer);
        }
Esempio n. 11
0
        public static void QueryFeatures(this MapView map, CartoSQLService service, LocalVectorDataSource source, PointStyle style, string query)
        {
            System.Threading.Tasks.Task.Run(delegate
            {
                FeatureCollection features = service.QueryFeatures(query, map.Options.BaseProjection);

                for (int i = 0; i < features.FeatureCount; i++)
                {
                    Feature feature = features.GetFeature(i);

                    PointGeometry geometry = (PointGeometry)feature.Geometry;

                    var point = new Point(geometry, style);
                    source.Add(point);
                }
            });
        }
Esempio n. 12
0
        public void FindAttractions(FeatureCollection collection, Action <int> complete)
        {
            System.Threading.Tasks.Task.Run(delegate
            {
                int result = 0;

                for (int i = 0; i < collection.FeatureCount; i++)
                {
                    Feature feature = collection.GetFeature(i);

                    if (feature.Geometry is LineGeometry)
                    {
                        result += ShowAttractions(feature.Geometry);
                    }
                }

                complete(result);
            });
        }
Esempio n. 13
0
        public void SetupFeatures(FeatureCollection pathProcessFeaturesCollection)
        {
            var dates = pathProcessFeaturesCollection.GetFeature <ITimeStepsFeature>();

            dates.AddDates(_asianDates);
        }
Esempio n. 14
0
        public void SetupFeatures(FeatureCollection features)
        {
            var dates = features.GetFeature <ITimeStepsFeature>();

            dates.AddDates(EventDates);
        }
Esempio n. 15
0
 public void SetupFeatures(FeatureCollection pathProcessFeaturesCollection)
 {
     var mappingFeature = pathProcessFeaturesCollection.GetFeature <IPathMappingFeature>();
 }
        public static void ShowResult(this LocalVectorDataSource source, MapView map, GeocodingResult result, string title, string description, bool goToPosition)
        {
            source.Clear();

            var builder = new BalloonPopupStyleBuilder();

            builder.LeftMargins  = new BalloonPopupMargins(0, 0, 0, 0);
            builder.TitleMargins = new BalloonPopupMargins(6, 3, 6, 3);
            builder.CornerRadius = 5;
            // Make sure this label is shown on top of all other labels
            builder.PlacementPriority = 10;

            FeatureCollection collection = result.FeatureCollection;
            int count = collection.FeatureCount;

            MapPos   position = new MapPos();
            Geometry geometry;

            for (int i = 0; i < count; i++)
            {
                geometry = collection.GetFeature(i).Geometry;
                var color = new Carto.Graphics.Color(0, 100, 200, 150);

                var pointBuilder = new PointStyleBuilder();
                pointBuilder.Color = color;

                var lineBuilder = new LineStyleBuilder();
                lineBuilder.Color = color;

                var polygonBuilder = new PolygonStyleBuilder();
                polygonBuilder.Color = color;

                VectorElement element = null;

                if (geometry is PointGeometry)
                {
                    element = new Point(geometry as PointGeometry, pointBuilder.BuildStyle());
                }
                else if (geometry is LineGeometry)
                {
                    element = new Line(geometry as LineGeometry, lineBuilder.BuildStyle());
                }
                else if (geometry is PolygonGeometry)
                {
                    element = new Polygon(geometry as PolygonGeometry, polygonBuilder.BuildStyle());
                }
                else if (geometry is MultiGeometry)
                {
                    var collectionBuilder = new GeometryCollectionStyleBuilder();
                    collectionBuilder.PointStyle   = pointBuilder.BuildStyle();
                    collectionBuilder.LineStyle    = lineBuilder.BuildStyle();
                    collectionBuilder.PolygonStyle = polygonBuilder.BuildStyle();

                    element = new GeometryCollection(geometry as MultiGeometry, collectionBuilder.BuildStyle());
                }

                if (element != null)
                {
                    position = geometry.CenterPos;
                    source.Add(element);
                }
            }

            if (goToPosition)
            {
                map.SetFocusPos(position, 1.0f);
                map.SetZoom(16, 1.0f);
            }

            var popup = new BalloonPopup(position, builder.BuildStyle(), title, description);

            source.Add(popup);
        }
        void LoadData(VectorElementVector elements, MapPos min, MapPos max, float zoom)
        {
            // Load and parse JSON
            string bbox = EncodeBBox(min.X, min.Y, max.X, max.Y);

            string unencoded = query.Replace("!bbox!", bbox);

            unencoded = unencoded.Replace("zoom('!scale_denominator!')", Convert.ToString(zoom));

            // UrlEncode does not replace parentheses by default as they are valid url elements
            string encoded = System.Web.HttpUtility.UrlEncode(unencoded).EncodeParenthesis();

            string fullPath = baseUrl + "?format=GeoJSON&q=" + encoded;

            try
            {
                string json = GetString(fullPath);

                GeoJSONGeometryReader geoJsonParser = new GeoJSONGeometryReader();
                FeatureCollection     features      = geoJsonParser.ReadFeatureCollection(json);

                for (int i = 0; i < features.FeatureCount; i++)
                {
                    Geometry geom  = features.GetFeature(i).Geometry;
                    Variant  props = features.GetFeature(i).Properties;

                    // Create object based on given style
                    VectorElement element;

                    if (style is PointStyle)
                    {
                        element = new Point((PointGeometry)geom, (PointStyle)style);
                    }
                    else if (style is MarkerStyle)
                    {
                        element = new Marker(geom, (MarkerStyle)style);
                    }
                    else if (style is LineStyle)
                    {
                        element = new Line((LineGeometry)geom, (LineStyle)style);
                    }
                    else if (style is PolygonStyle)
                    {
                        element = new Polygon((PolygonGeometry)geom, (PolygonStyle)style);
                    }
                    else
                    {
                        string text = "Object creation not implemented yet for style: " + style.SwigGetClassNameStyle();
                        Carto.Utils.Log.Debug(text);
                        break;
                    }

                    // Add all properties as MetaData, so you can use it with click handling
                    for (int j = 0; j < props.ObjectKeys.Count; j++)
                    {
                        var key = props.ObjectKeys[j];
                        var val = props.GetObjectElement(key);
                        element.SetMetaDataElement(key, val);
                    }

                    elements.Add(element);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }