Пример #1
0
        private static List <GeospatialAreaStaging> ConvertToGeospatialStagings(string responseData, DatabaseEntities dbContext, string databaseConnectionString)
        {
            var featureCollection =
                JsonConvert.DeserializeObject <FeatureCollection>(responseData, new GeometryConverter());

            if (!featureCollection.Features.Any())
            {
                throw new Exception("No geospatial area features were returned from the endpoint.");
            }

            // Clear out staging table
            var tenantID         = HttpRequestStorage.Tenant.TenantID;
            var stagingsToDelete = dbContext.GeospatialAreaStagings.ToList();

            dbContext.AllGeospatialAreaStagings.RemoveRange(stagingsToDelete);
            dbContext.SaveChangesWithNoAuditing(tenantID);

            var ogr2OgrCommandLineRunner = new Ogr2OgrCommandLineRunner(FirmaWebConfiguration.Ogr2OgrExecutable,
                                                                        Ogr2OgrCommandLineRunner.DefaultCoordinateSystemId,
                                                                        FirmaWebConfiguration.HttpRuntimeExecutionTimeout.TotalMilliseconds);

            ogr2OgrCommandLineRunner.ImportGeoJsonToMsSql(responseData,
                                                          databaseConnectionString,
                                                          "GeospatialAreaStaging",
                                                          $"SELECT {tenantID} as TenantID, Name as Name, GlobalID as ExternalID",
                                                          false);
            return(dbContext.GeospatialAreaStagings.ToList());
        }
Пример #2
0
        private static void StageFeatureCollection(FeatureCollection newLSPCBasinFeatureCollection)
        {
            var jsonFeatureCollection = JsonConvert.SerializeObject(newLSPCBasinFeatureCollection);

            var ogr2OgrCommandLineRunner = new Ogr2OgrCommandLineRunner(NeptuneWebConfiguration.Ogr2OgrExecutable,
                                                                        CoordinateSystemHelper.NAD_83_HARN_CA_ZONE_VI_SRID, 600000);

            ogr2OgrCommandLineRunner.ImportGeoJsonToMsSql(jsonFeatureCollection,
                                                          NeptuneWebConfiguration.DatabaseConnectionString, "LSPCBasinStaging",
                                                          "LSPC_BASIN as LSPCBasinKey, Name as LSPCBasinName",
                                                          CoordinateSystemHelper.NAD_83_HARN_CA_ZONE_VI_SRID, CoordinateSystemHelper.NAD_83_HARN_CA_ZONE_VI_SRID);
        }
Пример #3
0
        private static void StageFeatureCollection(FeatureCollection newPrecipitationZoneFeatureCollection)
        {
            var jsonFeatureCollection = JsonConvert.SerializeObject(newPrecipitationZoneFeatureCollection);

            var ogr2OgrCommandLineRunner = new Ogr2OgrCommandLineRunner(NeptuneWebConfiguration.Ogr2OgrExecutable,
                                                                        CoordinateSystemHelper.NAD_83_HARN_CA_ZONE_VI_SRID, 600000);

            ogr2OgrCommandLineRunner.ImportGeoJsonToMsSql(jsonFeatureCollection,
                                                          NeptuneWebConfiguration.DatabaseConnectionString, "PrecipitationZoneStaging",
                                                          "ID as PrecipitationZoneKey, RainfallZo as DesignStormwaterDepthInInches",
                                                          CoordinateSystemHelper.NAD_83_HARN_CA_ZONE_VI_SRID, CoordinateSystemHelper.NAD_83_HARN_CA_ZONE_VI_SRID);
        }
        private static void StageFeatureCollection(FeatureCollection newRegionalSubbasinFeatureCollection)
        {
            var jsonFeatureCollection = JsonConvert.SerializeObject(newRegionalSubbasinFeatureCollection);

            var ogr2OgrCommandLineRunner = new Ogr2OgrCommandLineRunner(NeptuneWebConfiguration.Ogr2OgrExecutable,
                                                                        CoordinateSystemHelper.NAD_83_HARN_CA_ZONE_VI_SRID, 600000);

            ogr2OgrCommandLineRunner.ImportGeoJsonToMsSql(jsonFeatureCollection,
                                                          NeptuneWebConfiguration.DatabaseConnectionString, "RegionalSubbasinStaging",
                                                          "CatchIDN as OCSurveyCatchmentID, DwnCatchIDN as OCSurveyDownstreamCatchmentID, DrainID as DrainID, Watershed as Watershed",
                                                          // transform from 2230 to 2771 here to avoid precision errors introduced by asking arc to do it
                                                          CoordinateSystemHelper.NAD_83_CA_ZONE_VI_SRID, CoordinateSystemHelper.NAD_83_HARN_CA_ZONE_VI_SRID);
        }