/// <summary>
        /// Creates a <see cref="IFeatureBasedMapDataLayer"/> based on <paramref name="data"/>.
        /// </summary>
        /// <param name="data">The <see cref="FeatureBasedMapData"/> to create a <see cref="IFeatureBasedMapDataLayer"/> from.</param>
        /// <returns>A <see cref="IFeatureBasedMapDataLayer"/> instance.</returns>
        /// <exception cref="NotSupportedException">Thrown when the given <paramref name="data"/> type is not supported.</exception>
        public static IFeatureBasedMapDataLayer Create(FeatureBasedMapData data)
        {
            var mapPointData = data as MapPointData;

            if (mapPointData != null)
            {
                return(new MapPointDataLayer(mapPointData));
            }

            var mapLineData = data as MapLineData;

            if (mapLineData != null)
            {
                return(new MapLineDataLayer(mapLineData));
            }

            var mapPolygonData = data as MapPolygonData;

            if (mapPolygonData != null)
            {
                return(new MapPolygonDataLayer(mapPolygonData));
            }

            throw new NotSupportedException($"FeatureBasedMapData of type {data.GetType().Name} is not supported.");
        }
Пример #2
0
        private void DrawMapData(FeatureBasedMapData featureBasedMapData)
        {
            IFeatureBasedMapDataLayer featureBasedMapDataLayer = FeatureBasedMapDataLayerFactory.Create(featureBasedMapData);

            var drawnMapData = new DrawnMapData
            {
                FeatureBasedMapData      = featureBasedMapData,
                FeatureBasedMapDataLayer = featureBasedMapDataLayer
            };

            drawnMapData.Observer = new Observer(() =>
            {
                mapDataLayersToUpdate.Add(drawnMapData.FeatureBasedMapDataLayer);
                StartUpdateTimer();
            })
            {
                Observable = featureBasedMapData
            };

            drawnMapDataList.Add(drawnMapData);

            if (!Projection.Equals(featureBasedMapDataLayer.Projection))
            {
                featureBasedMapDataLayer.Reproject(Projection);
            }

            map.Layers.Add(featureBasedMapDataLayer);
        }
Пример #3
0
        /// <summary>
        /// Converts the given <paramref name="mapData"/> to <see cref="FeatureBasedMapData"/>
        /// implementing <see cref="IRemovable"/>.
        /// </summary>
        /// <param name="mapData">The map data to convert.</param>
        /// <returns>A new <see cref="FeatureBasedMapData"/> implementing <see cref="IRemovable"/>.</returns>
        /// <exception cref="NotSupportedException">Thrown when the type <paramref name="mapData"/>
        /// could not be converted.</exception>
        public static FeatureBasedMapData FromFeatureBasedMapData(FeatureBasedMapData mapData)
        {
            var mapPointData = mapData as MapPointData;

            if (mapPointData != null)
            {
                return(new RemovableMapPointData(mapPointData.Name, mapPointData.Style)
                {
                    Features = mapPointData.Features
                });
            }

            var mapLineData = mapData as MapLineData;

            if (mapLineData != null)
            {
                return(new RemovableMapLineData(mapLineData.Name, mapLineData.Style)
                {
                    Features = mapLineData.Features
                });
            }

            var mapPolygonData = mapData as MapPolygonData;

            if (mapPolygonData != null)
            {
                return(new RemovableMapPolygonData(mapPolygonData.Name, mapPolygonData.Style)
                {
                    Features = mapPolygonData.Features
                });
            }

            throw new NotSupportedException($"The given {nameof(mapData)} was not convertible to {typeof(IRemovable).Name} data.");
        }
        private void SetCalculationsMapData <TCalculationScenario>(FeatureBasedMapData calculationsMapData)
            where TCalculationScenario : IPipingCalculationScenario <PipingInput>
        {
            IEnumerable <TCalculationScenario> calculations =
                FailureMechanism.CalculationsGroup.GetCalculations().OfType <TCalculationScenario>();

            calculationsMapData.Features = PipingMapDataFeaturesFactory.CreateCalculationFeatures(calculations);
        }
Пример #5
0
        /// <summary>
        /// Creates a new instance of <see cref="FeatureBasedMapDataContext"/>.
        /// </summary>
        /// <param name="wrappedData">The <see cref="FeatureBasedMapData"/> to wrap.</param>
        /// <param name="parentMapData">The parent <see cref="MapDataCollectionContext"/>
        /// the <paramref name="wrappedData"/> belongs to.</param>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public FeatureBasedMapDataContext(FeatureBasedMapData wrappedData, MapDataCollectionContext parentMapData)
            : base(wrappedData)
        {
            if (parentMapData == null)
            {
                throw new ArgumentNullException(nameof(parentMapData));
            }

            ParentMapData = parentMapData;
        }
        public void Image_WithContext_ReturnExpectedImage(FeatureBasedMapData mapData, Image expectedImage)
        {
            // Setup
            FeatureBasedMapDataContext context = GetContext(mapData);

            // Call
            Image image = info.Image(context);

            // Assert
            TestHelper.AssertImagesAreEqual(expectedImage, image);
        }
Пример #7
0
        private static IEnumerable <ReadDuneLocation> CreateDuneLocations(FeatureBasedMapData locationsData)
        {
            foreach (MapFeature locationData in locationsData.Features)
            {
                Point2D location = locationData.MapGeometries.First().PointCollections.First().First();

                object nameValue = locationData.MetaData[nameKey];
                string name      = nameValue?.ToString() ?? string.Empty;

                int    coastalAreaId = Convert.ToInt32(locationData.MetaData[coastalAreaIdKey]);
                double offset        = Convert.ToDouble(locationData.MetaData[offsetKey]);
                double orientation   = Convert.ToDouble(locationData.MetaData[orientationKey]);
                double d50           = Convert.ToDouble(locationData.MetaData[d50Key]);

                yield return(new ReadDuneLocation(name, location, coastalAreaId, offset, orientation, d50));
            }
        }
Пример #8
0
        /// <summary>
        /// Creates a new feature from <paramref name="featureBasedMapData"/> and adds it to the in-memory shapefile.
        /// </summary>
        /// <param name="featureBasedMapData">The <see cref="FeatureBasedMapData"/> to add to the in-memory shapefile as a feature.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="featureBasedMapData"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when:
        /// <list type="bullet">
        /// <item>A <paramref name="featureBasedMapData"/> contains different metadata keys
        /// than the <paramref name="featureBasedMapData"/> of the first call to <see cref="CopyToFeature"/>.</item>
        /// <item><paramref name="featureBasedMapData"/> does not contain exactly one <see cref="Feature"/>.</item>
        /// </list>
        /// </exception>
        public void CopyToFeature(FeatureBasedMapData featureBasedMapData)
        {
            if (featureBasedMapData == null)
            {
                throw new ArgumentNullException(nameof(featureBasedMapData));
            }

            if (featureBasedMapData.Features.Count() != 1)
            {
                throw new ArgumentException(Resources.ShapeFileWriterBase_CopyToFeature_Mapdata_can_only_contain_one_feature);
            }

            MapFeature mapFeature = featureBasedMapData.Features.First();

            EnsureAttributeTableExists(mapFeature);
            IFeature feature = AddFeature(mapFeature);

            CopyMetaDataFromMapFeatureToAttributeTable(mapFeature, feature);
        }
Пример #9
0
        /// <summary>
        /// Creates a new instance of <see cref="CategoryThemeProperties{T}"/>.
        /// </summary>
        /// <param name="categoryTheme">The theme to create the property info panel for.</param>
        /// <param name="attributeName">The name of the attribute on which <paramref name="categoryTheme"/>
        /// is based on.</param>
        /// <param name="mapData">The <see cref="FeatureBasedMapData"/> the <paramref name="categoryTheme"/> belongs to.</param>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        protected CategoryThemeProperties(TCategoryTheme categoryTheme, string attributeName, FeatureBasedMapData mapData)
        {
            if (categoryTheme == null)
            {
                throw new ArgumentNullException(nameof(categoryTheme));
            }

            if (attributeName == null)
            {
                throw new ArgumentNullException(nameof(attributeName));
            }

            if (mapData == null)
            {
                throw new ArgumentNullException(nameof(mapData));
            }

            data               = categoryTheme;
            MapData            = mapData;
            this.attributeName = attributeName;
        }
Пример #10
0
        /// <summary>
        /// Creates an <see cref="IEnumerable{T}"/> of <see cref="ReadDuneLocation"/> based on the line features within the embedded shape file.
        /// </summary>
        /// <returns>An <see cref="IEnumerable{T}"/> of <see cref="ReadDuneLocation"/>.</returns>
        public IEnumerable <ReadDuneLocation> ReadDuneLocations()
        {
            using (var embeddedResourceFileWriter = new EmbeddedResourceFileWriter(typeof(DuneLocationsReader).Assembly,
                                                                                   true,
                                                                                   "RSPstelsel.shp",
                                                                                   "RSPstelsel.dbf",
                                                                                   "RSPstelsel.cpg",
                                                                                   "RSPstelsel.sbn",
                                                                                   "RSPstelsel.sbx",
                                                                                   "RSPstelsel.shx"))
            {
                string filePath = Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "RSPstelsel.shp");

                var readDuneLocations = new List <ReadDuneLocation>();
                using (var pointShapeReader = new PointShapeFileReader(filePath))
                {
                    FeatureBasedMapData locationsData = pointShapeReader.ReadShapeFile();
                    readDuneLocations.AddRange(CreateDuneLocations(locationsData));
                }

                return(readDuneLocations);
            }
        }
 private static FeatureBasedMapDataContext GetContext(FeatureBasedMapData mapData, MapDataCollectionContext parentMapDataCollectionContext = null)
 {
     return(new FeatureBasedMapDataContext(mapData, parentMapDataCollectionContext ?? new MapDataCollectionContext(new MapDataCollection("test"), null)));
 }
 private void AddFeatureBasedMapDataToMapDataCollection(FeatureBasedMapData importedMapData)
 {
     ImportTarget.Add(RemovableMapDataConverter.FromFeatureBasedMapData(importedMapData));
 }
Пример #13
0
 public TestCategoryThemeProperties(string attributeName, TestCategoryTheme categoryTheme, FeatureBasedMapData mapData)
     : base(categoryTheme, attributeName, mapData)
 {
 }