-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Made changes to appropriate java files to fix raster download methods… #34
Open
bhickson
wants to merge
5
commits into
OpenGeoportal:master
Choose a base branch
from
bhickson:wcsRequest_BBFix
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
92d33e3
Create setSortableLayers function
bhickson 44d356e
Add layerId as id value for each rowContainer
bhickson 08e0761
Change cusor to signify drag and drop ability
bhickson 7145e0c
Merge pull request #1 from bhickson/previewedLayers_sortable
bhickson c3a6e38
Made changes to appropriate java files to fix raster download methods…
bhickson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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 |
---|---|---|
|
@@ -2,6 +2,9 @@ | |
|
||
import java.util.List; | ||
|
||
// BEN ADDED | ||
import java.util.HashMap; | ||
// | ||
import org.geotools.factory.Hints; | ||
import org.geotools.geometry.jts.ReferencedEnvelope; | ||
import org.geotools.referencing.ReferencingFactoryFinder; | ||
|
@@ -30,8 +33,8 @@ public static Boolean supports(List<String> supportedList, String testValue){ | |
} | ||
return false; | ||
} | ||
public static String createWcsGetCoverageRequest(String layerName, CoverageOffering1_0_0 coverageOffering, BoundingBox bounds, int epsgCode, String outputFormat) throws Exception { | ||
|
||
public static String createWcsGetCoverageRequest(String layerName, CoverageOffering1_0_0 coverageOffering, BoundingBox bounds, int epsgCode, String outputFormat, BoundingBox nativeBbox) throws Exception { | ||
//http://data.fao.org/maps/wcs?service=WCS&version=1.0.0&request=GetCoverage&coverage=lus_mna_31661&bbox=-13.166733,39.766613,12.099957,63.333236&crs=EPSG:4326&format=geotiff&width=917&height=331 | ||
|
||
List<String> supportedFormats = coverageOffering.getSupportedFormats(); | ||
|
@@ -46,23 +49,67 @@ public static String createWcsGetCoverageRequest(String layerName, CoverageOffer | |
Hints hints = new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE); | ||
CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG", hints); | ||
CoordinateReferenceSystem sourceCRS = factory.createCoordinateReferenceSystem("EPSG:4326"); | ||
|
||
|
||
//The bounding box is created in EPSG 4326. The line below takes the corrdinates given and references to the sourceCRS (EPSG:4326). | ||
//The envelope is then transformed to the native (targetCRS) bounds below. | ||
ReferencedEnvelope envelope = new ReferencedEnvelope(bounds.getMinX(), bounds.getMaxX(), bounds.getMinY(), bounds.getMaxY(), sourceCRS); | ||
logger.info("requested Bounds: " + OgpUtils.referencedEnvelopeToString(envelope)); | ||
|
||
// Transform using 10 sample points around the envelope | ||
|
||
CoordinateReferenceSystem targetCRS = factory.createCoordinateReferenceSystem(coverageOffering.getSupportedCRSs().get(0)); | ||
|
||
ReferencedEnvelope result = envelope.transform(targetCRS, true, 10); | ||
|
||
String getCoverageRequest = "service=WCS&version=" + VERSION + | ||
ReferencedEnvelope nativeRefEnv = new ReferencedEnvelope(nativeBbox.getMinX(), nativeBbox.getMaxX(), nativeBbox.getMinY(), nativeBbox.getMaxY(), targetCRS); | ||
|
||
Double resX = coverageOffering.getRectifiedGrid().getResx(); | ||
Double resY = coverageOffering.getRectifiedGrid().getResy(); | ||
|
||
Double xMin, yMin, xMax, yMax; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The following section is where the bounding box is snapped to whole pixels rather than arbitrarily cutting through them. |
||
if ( nativeRefEnv.getMinimum(0) > result.getMinimum(0)){ | ||
xMin = nativeRefEnv.getMinimum(0); | ||
} else { | ||
Double x_a = (Math.abs(result.getMinimum(0) - nativeRefEnv.getMinimum(0)))/resX; | ||
xMin = nativeRefEnv.getMinimum(0) + (x_a.intValue() * resX); } | ||
|
||
if ( nativeRefEnv.getMinimum(1) > result.getMinimum(1)){ | ||
yMin = nativeRefEnv.getMinimum(1); | ||
} else { | ||
Double y_a = (Math.abs(result.getMinimum(1) - nativeRefEnv.getMinimum(1)))/resY; | ||
yMin = nativeRefEnv.getMinimum(1) + (y_a.intValue() * resY); } | ||
|
||
|
||
if ( nativeRefEnv.getMaximum(0) < result.getMaximum(0)){ | ||
xMax = nativeRefEnv.getMaximum(0); | ||
} else { | ||
Double x_b = (Math.abs(result.getMaximum(0) - nativeRefEnv.getMaximum(0)))/resX; | ||
xMax = nativeRefEnv.getMaximum(0) - (x_b.intValue() * resX); } | ||
|
||
|
||
if ( nativeRefEnv.getMaximum(1) < result.getMaximum(1)){ | ||
yMax = nativeRefEnv.getMaximum(1); | ||
} else { | ||
Double y_b = (Math.abs(result.getMaximum(1) - nativeRefEnv.getMaximum(1)))/resY; | ||
yMax = nativeRefEnv.getMaximum(1) - (y_b.intValue() * resY); } | ||
|
||
String bbox = "&bbox=" + Double.toString(xMin) + "," + Double.toString(yMin) + "," + Double.toString(xMax) + "," + Double.toString(yMax); | ||
Double dwidth = (Math.abs(xMax - xMin))/resX; | ||
Double dheight = (Math.abs(yMax - yMin))/resY; | ||
int width = dwidth.intValue(); | ||
int height = dheight.intValue(); | ||
|
||
String widthHeight = "&width=" + width + "&height=" + height; | ||
|
||
String getCoverageRequest = "service=WCS&version=" + VERSION + | ||
"&request=GetCoverage&coverage=" + layerName + | ||
"&bbox=" + OgpUtils.referencedEnvelopeToString(result) + | ||
bbox + | ||
//"&bbox=" + OgpUtils.referencedEnvelopeToString(result) + | ||
// "&bbox=" + OgpUtils.referencedEnvelopeToString(result) + | ||
"&crs=" + coverageOffering.getSupportedCRSs().get(0) + | ||
"&format=" + outputFormat; | ||
|
||
getCoverageRequest += generateSize(coverageOffering.getRectifiedGrid()); | ||
|
||
"&format=" + outputFormat + | ||
widthHeight; | ||
|
||
return getCoverageRequest; | ||
} | ||
|
||
|
@@ -94,5 +141,35 @@ private static String generateSize(RectifiedGrid rgrid) throws Exception{ | |
|
||
return size; | ||
} | ||
/* | ||
private static String generateSize(RectifiedGrid rgrid) throws Exception{ | ||
Integer width = rgrid.getWidth(); | ||
Integer height = rgrid.getHeight(); | ||
|
||
String size = "&"; | ||
|
||
if (width.equals(null) || height.equals(null)){ | ||
Double resx = rgrid.getResx(); | ||
Double resy = rgrid.getResy(); | ||
if (!resx.isNaN() && !resy.isNaN()) { | ||
size += "resx="; | ||
size += Double.toString(resx); | ||
size += "&resy="; | ||
size += Double.toString(resy); | ||
} else { | ||
throw new Exception("invalid describe coverage response....could not form getCoverage request."); | ||
} | ||
|
||
} else { | ||
size += "width="; | ||
size += Integer.toString(width); | ||
size += "&height="; | ||
size += Integer.toString(height); | ||
} | ||
|
||
|
||
return size; | ||
}*/ | ||
|
||
|
||
} |
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
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer need generateSize. The getCoverageRequest string is composed near the end of the file.