-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
76 additions
and
129 deletions.
There are no files selected for viewing
122 changes: 45 additions & 77 deletions
122
gears/src/main/java/org/hortonmachine/gears/io/wcs/TestGeoeuskadi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> 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<String> 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); | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters