diff --git a/gears/src/main/java/org/hortonmachine/gears/io/wcs/TestGeoeuskadi.java b/gears/src/main/java/org/hortonmachine/gears/io/wcs/TestGeoeuskadi.java index f0b91990f..f4d6fb407 100644 --- a/gears/src/main/java/org/hortonmachine/gears/io/wcs/TestGeoeuskadi.java +++ b/gears/src/main/java/org/hortonmachine/gears/io/wcs/TestGeoeuskadi.java @@ -1,93 +1,61 @@ package org.hortonmachine.gears.io.wcs; import java.io.File; -import java.util.List; +import java.util.Arrays; +import java.util.stream.Collectors; -import org.hortonmachine.gears.io.wcs.readers.CoverageReaderParameters; import org.locationtech.jts.geom.Envelope; public class TestGeoeuskadi { - /* working url - * - * https://maps.isric.org/mapserv?map=/map/nitrogen.map - * &SERVICE=WCS - * &VERSION=2.0.1 - * &REQUEST=GetCoverage - * &COVERAGEID=nitrogen_5-15cm_Q0.5 - * &FORMAT=image/tiff - * &SUBSET=X(-1784000,-1140000) - * &SUBSET=Y(1356000,1863000) - * &SUBSETTINGCRS=http://www.opengis.net/def/crs/EPSG/0/152160 - */ - public static void main(String[] args) throws Exception { - String outFolder = "C:\\Users\\hydrologis\\Dropbox\\G-ANT\\lavori\\2024_10_30_bilbao_aries\\WCS\\"; - - String SERVICE_URL = "https://geo.hazi.eus/ows"; -// String SERVICE_URL = "https://geo.hazi.eus/S2GEOEUSKADI_RGB/wcs"; -// String SERVICE_URL = "https://www.geo.euskadi.eus/geoeuskadi/services/U11/WCS_KARTOGRAFIA/MapServer/WCSServer"; - String coverageId = "0"; //S2GEOEUSKADI_RGB:S2A_20150818T110635806Z_RGB"; - String version = null; - - IWebCoverageService service = IWebCoverageService.getServiceForVersion(SERVICE_URL, version); - - System.out.println(service.getVersion()); - - // service.dumpCoverageFootprints(outFolder); - - // print list of coverage ids - System.out.println("Coverage ids:"); - List coverageIds = service.getCoverageIds(); - int index = 1; - for (String cid : coverageIds) { - System.out.println("\t" + index + ")" + cid); - index++; - } - - // print supported srids - int[] supportedSrids = service.getSupportedSrids(); - if (supportedSrids != null) { - System.out.println("Supported srids:"); - if (supportedSrids != null) - for (int srid : supportedSrids) { - System.out.println("\t" + srid); - } + String outFolder = "C:\\Users\\hydrologis\\Desktop\\TMP\\"; + + // REMOTE SENSING + String url = "https://geo.hazi.eus/S2GEOEUSKADI_RGB/wcs"; + String coverageId = "S2GEOEUSKADI_RGB:S2A_20150818T110046_RGB"; + String name = "geo_hazi_"; + + // LIDAR +// String url = "https://www.geo.euskadi.eus/geoeuskadi/services/U11/WCS_KARTOGRAFIA/MapServer/WCSServer"; +// String coverageId = null;//"1"; +// String name = "geo_euskadi_"; + + String version = "1.0.0"; + int sridInt = 25830; + int resol = 2000; + + Wcs wcs = new Wcs(url, version); + + System.out.println(wcs.version()); + + var ids = wcs.ids(); + if (ids != null){ + System.out.println("Available coverages:"); + for( String id : ids ) { + var summary = wcs.summary(id); + System.out.println(id + ") Title: " + summary.getTitle()); + var describe = wcs.describe(id); + System.out.println("\t" + "Formats: " + describe.getSupportedFormats().stream().collect(Collectors.joining(", "))); + System.out.println("\t" + "Srids: " + Arrays.toString(describe.getSupportedSrids())); + } } - // print supported formats - List supportedFormats = service.getSupportedFormats(); - if (supportedFormats != null) { - System.out.println("Supported formats:"); - if (supportedFormats != null) - for (String format : supportedFormats) { - System.out.println("\t" + format); - } + if(coverageId != null) { + // get coverage + var parameters = wcs.getReaderParameters(coverageId); + Envelope env = Wcs.evelope(504787.0, 4734309.0, 536275.0, 4754145.0); + parameters.bbox(env, sridInt); + parameters.rowsCols(resol, resol); + parameters.useExtendedAxisUrl(false); + parameters.format("GeoTIFF"); + + File file = new File(outFolder, name + "_" + resol + ".tiff"); + var cUrl = wcs.dumpCoverage(file.getAbsolutePath(), parameters); + + System.out.println("Coverage url: " + cUrl); } - // describe coverage -// String describeCoverageUrl = service.getDescribeCoverageUrl(coverageId); -// System.out.println(describeCoverageUrl); -// -// IDescribeCoverage describeCoverage = service.getDescribeCoverage(coverageId); -// System.out.println(describeCoverage); - - // get coverage - CoverageReaderParameters parameters = new CoverageReaderParameters(service, coverageId); - parameters.format("image/tiff"); - - Envelope env = Wcs.evelope(504787.0, 4734309.0, 536275.0, 4754145.0); - parameters.bbox(env, 25830); - // parameters.scaleFactor(0.01); - parameters.rowsCols(1000, 1000 ); - parameters.outputSrid(4326); - - File file = new File(outFolder, coverageId + "_1000.tiff"); - String url = service.getCoverage(file.getAbsolutePath(), parameters, null); - - System.out.println("Coverage url: " + url); - - } } diff --git a/gears/src/main/java/org/hortonmachine/gears/io/wcs/TestIsric.java b/gears/src/main/java/org/hortonmachine/gears/io/wcs/TestIsric.java index e9a3a0261..b6f2642ac 100644 --- a/gears/src/main/java/org/hortonmachine/gears/io/wcs/TestIsric.java +++ b/gears/src/main/java/org/hortonmachine/gears/io/wcs/TestIsric.java @@ -1,7 +1,9 @@ package org.hortonmachine.gears.io.wcs; import java.io.File; +import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; import org.hortonmachine.gears.io.wcs.readers.CoverageReaderParameters; import org.locationtech.jts.geom.Envelope; @@ -23,69 +25,46 @@ public class TestIsric { public static void main(String[] args) throws Exception { - String outFolder = "/Users/hydrologis/TMP/KLAB/WCS/DUMPS/"; + String outFolder = "C:\\Users\\hydrologis\\Desktop\\TMP\\"; String SERVICE_URL = "https://maps.isric.org/mapserv?map=/map/nitrogen.map"; String coverageId = "nitrogen_0-5cm_Q0.95"; + String name = "isric_"; String version = null; + int resol = 2000; - IWebCoverageService service = IWebCoverageService.getServiceForVersion(SERVICE_URL, version); + Wcs wcs = new Wcs(SERVICE_URL, version); - System.out.println(service.getVersion()); + System.out.println("Version:" + wcs.version()); + System.out.println("Formats: " + wcs.formats().stream().collect(Collectors.joining(", "))); + System.out.println("Srids: " + Arrays.toString(wcs.srids())); - // service.dumpCoverageFootprints(outFolder); - - // print list of coverage ids - System.out.println("Coverage ids:"); - List coverageIds = service.getCoverageIds(); - for (String cid : coverageIds) { - System.out.println("\t" + cid); - } - - // print supported srids - int[] supportedSrids = service.getSupportedSrids(); - if (supportedSrids != null) { - System.out.println("Supported srids:"); - if (supportedSrids != null) - for (int srid : supportedSrids) { - System.out.println("\t" + srid); - } + var ids = wcs.ids(); + if (ids != null){ + System.out.println("Available coverages:"); + for( String id : ids ) { + var summary = wcs.summary(id); + System.out.println(id + ") Title: " + summary.getTitle()); + } } - // print supported formats - List supportedFormats = service.getSupportedFormats(); - if (supportedFormats != null) { - System.out.println("Supported formats:"); - if (supportedFormats != null) - for (String format : supportedFormats) { - System.out.println("\t" + format); - } - } - - // describe coverage - String describeCoverageUrl = service.getDescribeCoverageUrl(coverageId); - System.out.println(describeCoverageUrl); - - IDescribeCoverage describeCoverage = service.getDescribeCoverage(coverageId); - System.out.println(describeCoverage); // get coverage - CoverageReaderParameters parameters = new CoverageReaderParameters(service, coverageId); - parameters.format("image/tiff"); - - Envelope env = Wcs.evelope(12.263, -17.05, 16.763, -11.365); - parameters.bbox(env, 4326); - // Envelope env = Wcs.evelope(-1784000, 1356000, -1140000, 1863000); - // parameters.bbox(env, 152160); - // parameters.scaleFactor(0.01); - // parameters.rowsCols(new int[] { 1000, 1000 }); // TODO in case of 100 a check on gridenvelope needs to be done - parameters.outputSrid(4326); - - File file = new File(outFolder, coverageId + ".tiff"); - String url = service.getCoverage(file.getAbsolutePath(), parameters, null); - - System.out.println("Coverage url: " + url); - + if(coverageId != null) { + // get coverage + var parameters = wcs.getReaderParameters(coverageId); + parameters.format("image/tiff"); + + Envelope env = Wcs.evelope(12.263, -17.05, 16.763, -11.365); + parameters.bbox(env, 4326); + parameters.rowsCols(resol, resol); + parameters.outputSrid(4326); + + File file = new File(outFolder, name + "_" + resol + ".tiff"); + var cUrl = wcs.dumpCoverage(file.getAbsolutePath(), parameters); + + System.out.println("Coverage url: " + cUrl); + } } }