Ejemplo n.º 1
0
        ///<inheritdoc />
        public GpxFile ToGpx(FeatureCollection collection)
        {
            var gpx = new GpxFile
            {
                Metadata = new GpxMetadata(collection.FirstOrDefault(f => f.Attributes.Exists(CREATOR))
                                           ?.Attributes[CREATOR]?.ToString() ?? GpxDataContainerConverter.ISRAEL_HIKING_MAP + "_geojson")
            };

            gpx.Waypoints.AddRange(collection.Where(f => f.Geometry is Point)
                                   .Select(CreateWaypoint)
                                   .Union(collection.Where(f => f.Geometry is MultiPoint)
                                          .SelectMany(CreateWayPointsFromMultiPoint))
                                   .ToList());
            gpx.Routes.AddRange(collection.Where(f => f.Geometry is LineString)
                                .Select(CreateRouteFromLineString)
                                .Union(collection.Where(f => f.Geometry is Polygon).Select(CreateRouteFromPolygon))
                                .Union(collection.Where(f => f.Geometry is MultiPolygon)
                                       .SelectMany(CreateRoutesFromMultiPolygon))
                                .ToList());
            gpx.Tracks.AddRange(collection.Where(f => f.Geometry is MultiLineString)
                                .SelectMany(CreateTracksFromMultiLineString)
                                .ToList());
            gpx.UpdateBounds();
            return(gpx);
        }
Ejemplo n.º 2
0
        private void GetFeaturesToAdd(WebCreator webDefinition, FeatureCollection sourceFeatures,
                                      FeatureCollection baseFeatures,
                                      bool canGetSourceFeatureNames, FeatureDefinitionScope featureScope)
        {
            webDefinition.AppManifest.AddFeatures = new Dictionary <string, FeatureAdderCreator>();
            var foundAddFeatures = false;

            foreach (var sourceFeature in sourceFeatures)
            {
                var baseFeature =
                    baseFeatures.FirstOrDefault(f => f.DefinitionId == sourceFeature.DefinitionId);

                if (baseFeature == null)
                {
                    foundAddFeatures = true;
                    var name = canGetSourceFeatureNames
                        ? sourceFeature.DisplayName
                        : sourceFeature.DefinitionId.ToString();
                    OnVerboseNotify($"Found {featureScope} scoped feature to add {name}.");
                    webDefinition.AppManifest.AddFeatures[name] = new FeatureAdderCreator
                    {
                        DisplayName            = name,
                        FeatureDefinitionScope = featureScope,
                        FeatureId = sourceFeature.DefinitionId,
                        Force     = true
                    };
                }
            }
            if (foundAddFeatures)
            {
                OnVerboseNotify(
                    "Found features to add. Note that the support for features using CSOM is pretty limited and there is no guarantee they are in the proper order in the manifest. You should test and adjust as needed!");
            }
        }
Ejemplo n.º 3
0
 protected Feature GetFeature(FeatureCollection features, FeatureDefinition featureModel)
 {
     return features.FirstOrDefault(f => f.DefinitionId == featureModel.Id);
 }
Ejemplo n.º 4
0
 protected Feature GetFeature(FeatureCollection features, FeatureDefinition featureModel)
 {
     return(features.FirstOrDefault(f => f.DefinitionId == featureModel.Id));
 }