Exemplo n.º 1
0
        private static void TileNorway()
        {
            var layer = new TiledVectorLayer("test2", WebMercator.BoundingBox1, 39135.75848201024 * 4);
            var store = new DiskTileStore(layer);

            store.Wipe();
            var tiler    = new VectorTiler(store, layer);
            var filename = FileLocator.FindFileInTree(@"data\norway.geojson");
            FeatureCollection        norway       = JsonConvert.DeserializeObject <FeatureCollection>(File.ReadAllText(filename));
            List <OmrådeMedGeometry> partOfNorway = new List <OmrådeMedGeometry>();

            foreach (var feature in norway.Features)
            {
                partOfNorway.Add(new OmrådeMedGeometry(new Område(3581, AreaType.Land), DotSpatialGeometry.From(feature)));
            }
            foreach (var omg in partOfNorway)
            {
                omg.Område.Number = -5;
            }
            for (int zoom = 0; zoom < 6; zoom++)
            {
                foreach (OmrådeMedGeometry polygon in partOfNorway)
                {
                    tiler.Update(polygon.Område, polygon.Geometry, zoom);
                }
            }
        }
Exemplo n.º 2
0
        private static SqlGeometry CreateMetadataArea(string fylke, int targetSrs)
        {
            SqlGeometry  metadataArea        = new SqlGeometry();
            const int    metadatapolygonEpsg = 3857;
            const string metadatapolygon     =
                "POLYGON((1102527.6959853824 9005963.546616036, 1237056.8657672927 9005963.546616036, 1237056.8657672927 9137740.98337968, 1102527.6959853824 9137740.98337968, 1102527.6959853824 9005963.546616036))";

            if (metadatapolygon.Length == 0)
            {
                var path  = FileLocator.FindFileInTree(@"Data\area\fylker.txt");
                var areas = AreaCollection.FromGeoJson(File.ReadAllText(path), 4326);

                foreach (var area in areas)
                {
                    if (area.Name.Equals(fylke))
                    {
                        metadataArea = area.Geometry;
                    }
                }
            }
            else
            {
                metadataArea        = SqlGeometry.Parse(metadatapolygon);
                metadataArea.STSrid = metadatapolygonEpsg;
                metadataArea        = MapProjection.Reproject(metadataArea, targetSrs);
            }
            return(metadataArea);
        }
Exemplo n.º 3
0
        private static void ImportGrid(string shapeFilePath, int sourceEpsgCode, RutenettType rutenettType)
        {
            string fullPath = FileLocator.FindFileInTree(Path.Combine(@"Data\Grid\SSB", shapeFilePath));

            var grid = GridImporter.ImportGrid(sourceEpsgCode, rutenettType, fullPath);

            GridImporter.BulkStore(grid);
        }
Exemplo n.º 4
0
        public static XDocument ReadXDocument(string xmlFilePath)
        {
            var       path           = FileLocator.FindFileInTree(xmlFilePath);
            string    gridMapXmlText = File.ReadAllText(path, Encoding.GetEncoding("iso-8859-1"));
            XDocument gridMapXml     = XDocument.Parse(gridMapXmlText);

            return(gridMapXml);
        }
Exemplo n.º 5
0
        private static Collection <NatureArea> GenerateNatureAreasFromShapeFile(string shapeFilePath, int epsgCode, string knr, int startFeature, int featureCount)
        {
            var natureAreas = new Collection <NatureArea>();

            shapeFilePath = FileLocator.FindFileInTree(shapeFilePath);
            Shapefile shapeFile  = Shapefile.OpenFile(shapeFilePath);
            var       endFeature = startFeature + featureCount < shapeFile.Features.Count
                ? startFeature + featureCount
                : shapeFile.Features.Count;

            for (var number = startFeature; number < endFeature; number++)
            {
                var feature = shapeFile.Features[number];
                var area    = new NatureArea {
                    UniqueId = new Identification()
                };

                var numberString = number.ToString();
                var guid         = "00000000-0000-0000-" + knr + "-";

                for (int i = 0; i < 12 - numberString.Length; ++i)
                {
                    guid += "0";
                }

                area.UniqueId.LocalId = new Guid(guid + numberString);

                area.UniqueId.NameSpace = "NBIC";
                area.UniqueId.VersionId = "1.0";

                area.Version = "1";
                area.Nivå    = Types.NatureLevel.Natursystem;

                area.Area = SqlGeometry.STGeomFromText(new SqlChars(feature.BasicGeometry.ToString()), epsgCode);

                var       natureAreaType = new NatureAreaType();
                const int rowOffset      = 0; // 1 for melhus
                natureAreaType.Code  = (string)feature.DataRow[rowOffset + 4];
                natureAreaType.Share = 1;
                if (feature.DataRow[rowOffset + 3] != DBNull.Value)
                {
                    var descriptionVariable      = new DescriptionVariable();
                    var descriptionVariableParts = ((string)feature.DataRow[rowOffset + 3]).Split('_');
                    descriptionVariable.Code  = descriptionVariableParts[0];
                    descriptionVariable.Value = descriptionVariableParts[1];
                    natureAreaType.AdditionalVariables.Add(descriptionVariable);
                }
                area.Parameters.Add(natureAreaType);

                area.Surveyed = DateTime.Parse(feature.DataRow[rowOffset + 5].ToString());
                area.Surveyer = new Contact {
                    Company = (string)feature.DataRow[rowOffset + 8]
                };
                natureAreas.Add(area);
            }
            return(natureAreas);
        }
Exemplo n.º 6
0
        public void ParseDataDeliveryTest_ParseOk()
        {
            string path = FileLocator.FindFileInTree(@"Data\NatureArea\NiNCoreImportExample.xml");
            string dataDeliveryXmlText = File.ReadAllText(path, Encoding.GetEncoding("iso-8859-1"));

            XDocument dataDeliveryXml = XDocument.Parse(dataDeliveryXmlText);

            Dataleveranse dataleveranse = DataleveranseParser.ParseDataleveranse(dataDeliveryXml);

            Assert.NotNull(dataleveranse);
        }
Exemplo n.º 7
0
        public DataleveranseValidatorTest()
        {
            //var findDirectoryInTree = TestSetup.FindDirectoryInTree(@"schema\cache\");
            var xsd     = FileLocator.FindFileInTree(@"schema\cache\ogc_schema_updates.rss");
            var xsdPath = Path.GetDirectoryName(xsd);

            GmlXmlResolver gmlXmlResolver = DataleveranseXmlGreier.CreateGmlXmlResolver(xsdPath);

            dataDeliveryImportValidator    = CreateValidator(gmlXmlResolver, @"schema\NiNCoreDataLeveranse.xsd");
            dataDeliveryExportValidator    = CreateValidator(gmlXmlResolver, @"schema\NiNCoreDataEksport.xsd");
            dataDeliveryMapImportValidator = CreateValidator(gmlXmlResolver, @"schema\NiNCoreGridLeveranse.xsd");
        }
Exemplo n.º 8
0
        private static DataleveranseValiderer CreateValidator(XmlResolver gmlXmlResolver, string xsdPath)
        {
            var schemas = new XmlSchemaSet {
                XmlResolver = gmlXmlResolver
            };

            using (StreamReader xsdMarkup = File.OpenText(FileLocator.FindFileInTree(xsdPath)))
            {
                var xmlReader = XmlReader.Create(xsdMarkup);
                schemas.Add("http://pavlov.itea.ntnu.no/NbicFiles", xmlReader);
            }

            return(new DataleveranseValiderer(schemas));
        }
Exemplo n.º 9
0
        public void TileNorway()
        {
            var filename = FileLocator.FindFileInTree(@"data\norway.geojson");
            FeatureCollection        norway       = JsonConvert.DeserializeObject <FeatureCollection>(File.ReadAllText(filename));
            List <OmrådeMedGeometry> partOfNorway = new List <OmrådeMedGeometry>();

            foreach (var feature in norway.Features)
            {
                partOfNorway.Add(new OmrådeMedGeometry(new Område(3581, AreaType.Land), DotSpatialGeometry.From(feature)));
            }
            foreach (var omg in partOfNorway)
            {
                omg.Område.Number = -5;
            }
            for (int zoom = 0; zoom < 6; zoom++)
            {
                foreach (OmrådeMedGeometry polygon in partOfNorway)
                {
                    tiler.Update(polygon.Område, polygon.Geometry, zoom);
                }
            }
        }
Exemplo n.º 10
0
        private static string GetDatabasePath()
        {
            var findDirectoryInTree = FileLocator.FindFileInTree(@"Database\001_Schema.sql");

            return(Path.GetDirectoryName(findDirectoryInTree));
        }