-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
5 changed files
with
138 additions
and
5 deletions.
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
65 changes: 65 additions & 0 deletions
65
src/community/wfs3/src/main/java/org/geoserver/wfs3/kvp/WFS3BBoxKvpParser.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,65 @@ | |||
/* (c) 2017 Open Source Geospatial Foundation - all rights reserved | |||
* This code is licensed under the GPL 2.0 license, available at the root | |||
* application directory. | |||
*/ | |||
package org.geoserver.wfs3.kvp; | |||
|
|||
import org.geoserver.wfs.kvp.BBoxKvpParser; | |||
import org.geotools.geometry.jts.ReferencedEnvelope; | |||
import org.geotools.referencing.CRS; | |||
import org.geotools.referencing.crs.DefaultGeographicCRS; | |||
import org.opengis.referencing.FactoryException; | |||
import org.opengis.referencing.NoSuchAuthorityCodeException; | |||
import org.opengis.referencing.crs.CoordinateReferenceSystem; | |||
|
|||
/** | |||
* A parser that allows dateline crossing envelopes. TODO: Same as the OpenSearch one, the class | |||
* will eventually have to be either moved to core or merged with its based class. | |||
* | |||
* @author Andrea Aime | |||
*/ | |||
public class WFS3BBoxKvpParser extends BBoxKvpParser { | |||
|
|||
@Override | |||
protected Object buildEnvelope( | |||
int countco, | |||
double minx, | |||
double miny, | |||
double minz, | |||
double maxx, | |||
double maxy, | |||
double maxz, | |||
String srs) | |||
throws NoSuchAuthorityCodeException, FactoryException { | |||
if (countco > 4) { | |||
throw new IllegalArgumentException( | |||
"Too many coordinates, openSearch cannot handle non flat envelopes yet"); | |||
} | |||
|
|||
CoordinateReferenceSystem crs = srs == null ? null : CRS.decode(srs, true); | |||
if (crs == null) { | |||
crs = DefaultGeographicCRS.WGS84; | |||
} | |||
minx = rollLongitude(minx); | |||
maxx = rollLongitude(maxx); | |||
|
|||
if (minx > maxx) { | |||
// dateline crossing case | |||
return new ReferencedEnvelope[] { | |||
new ReferencedEnvelope(minx, 180, miny, maxy, crs), | |||
new ReferencedEnvelope(-180, maxx, miny, maxy, crs), | |||
}; | |||
} else { | |||
return new ReferencedEnvelope(minx, maxx, miny, maxy, crs); | |||
} | |||
} | |||
|
|||
protected static double rollLongitude(final double x) { | |||
double mod = (x + 180) % 360; | |||
if (mod == 0) { | |||
return x > 0 ? 180 : -180; | |||
} else { | |||
return mod - 180; | |||
} | |||
} | |||
} |
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