Permalink
Browse files

Merge branch 'master' into featurecollection_cleanup_origional

  • Loading branch information...
2 parents e2c1b55 + 6e86475 commit 8e6d9e2af271833cc6ffb70f71ea810e5ac28914 jdeolive committed Nov 15, 2012
Showing with 3,136 additions and 1,281 deletions.
  1. +49 −109 modules/extension/wms/src/main/java/org/geotools/data/ows/Layer.java
  2. +40 −1 modules/extension/wms/src/main/java/org/geotools/data/ows/MultithreadedHttpClient.java
  3. +3 −3 modules/extension/wms/src/main/java/org/geotools/data/wms/xml/WMSComplexTypes.java
  4. +2 −1 modules/extension/wms/src/main/java/org/geotools/map/WMSCoverageReader.java
  5. +19 −0 modules/extension/wms/src/test/java/org/geotools/data/ows/MockHttpClient.java
  6. +9 −0 modules/extension/wms/src/test/java/org/geotools/data/ows/MockHttpResponse.java
  7. +143 −33 modules/extension/wms/src/test/java/org/geotools/data/wms/test/LocalGeoServerOnlineTest.java
  8. +57 −3 modules/extension/xsd/xsd-gml2/src/main/java/org/geotools/gml2/bindings/GML2ParsingUtils.java
  9. +1 −0 modules/extension/xsd/xsd-wfs/src/test/java/org/geotools/wfs/WFSParsingTest.java
  10. +93 −0 modules/library/main/src/main/java/org/geotools/data/ows/DelegateHTTPClient.java
  11. +56 −0 modules/library/main/src/main/java/org/geotools/data/ows/DelegateHTTPResponse.java
  12. +10 −0 modules/library/main/src/main/java/org/geotools/data/ows/HTTPClient.java
  13. +6 −0 modules/library/main/src/main/java/org/geotools/data/ows/HTTPResponse.java
  14. +98 −0 modules/library/main/src/main/java/org/geotools/data/ows/LoggingHTTPClient.java
  15. +52 −5 modules/library/main/src/main/java/org/geotools/data/ows/SimpleHttpClient.java
  16. +5 −5 modules/library/main/src/main/java/org/geotools/filter/visitor/CapabilitiesFilterSplitter.java
  17. +9 −9 .../library/main/src/main/java/org/geotools/filter/visitor/PostPreProcessFilterSplittingVisitor.java
  18. +30 −6 modules/library/main/src/main/java/org/geotools/styling/DefaultResourceLocator.java
  19. +3 −0 modules/library/main/src/main/java/org/geotools/styling/ExternalGraphicImpl.java
  20. +18 −0 modules/library/main/src/test/java/org/geotools/filter/visitor/CapabilitiesFilterSplitterTest.java
  21. +19 −0 ...rary/main/src/test/java/org/geotools/filter/visitor/PostPreProcessFilterSplittingVisitorTest.java
  22. +25 −0 modules/library/main/src/test/java/org/geotools/styling/DefaultResourceLocatorTest.java
  23. +20 −6 modules/library/metadata/src/main/java/org/geotools/factory/GeoTools.java
  24. +29 −11 modules/library/referencing/src/main/java/org/geotools/referencing/CRS.java
  25. +2 −0 ...les/library/referencing/src/main/java/org/geotools/referencing/operation/projection/Robinson.java
  26. +24 −1 ...es/library/referencing/src/test/resources/org/geotools/referencing/test-data/scripts/Robinson.txt
  27. +98 −100 modules/library/render/src/main/java/org/geotools/renderer/lite/RendererUtilities.java
  28. +47 −135 modules/library/render/src/main/java/org/geotools/renderer/lite/StreamingRenderer.java
  29. +151 −0 modules/library/render/src/test/java/org/geotools/renderer/lite/AttributeRenameFunction.java
  30. +4 −6 modules/library/render/src/test/java/org/geotools/renderer/lite/LabelObstacleTest.java
  31. +38 −11 modules/library/render/src/test/java/org/geotools/renderer/lite/RenderUtilitiesTest.java
  32. +119 −10 modules/library/render/src/test/java/org/geotools/renderer/lite/RenderingTransformationTest.java
  33. +63 −0 modules/library/render/src/test/java/org/geotools/renderer/lite/ReprojectCollectionFunction.java
  34. +3 −1 modules/library/render/src/test/resources/META-INF/services/org.opengis.filter.expression.Function
  35. +40 −0 modules/library/render/src/test/resources/org/geotools/renderer/lite/test-data/attributeRename.sld
  36. +39 −0 ...ibrary/render/src/test/resources/org/geotools/renderer/lite/test-data/attributeRenameNoInvert.sld
  37. +32 −0 modules/library/render/src/test/resources/org/geotools/renderer/lite/test-data/reproject-rt.sld
  38. +61 −0 modules/plugin/epsg-hsql/src/test/java/org/geotools/referencing/CRSTest.java
  39. +15 −8 modules/plugin/epsg-hsql/src/test/java/org/geotools/referencing/factory/epsg/DefaultFactoryTest.java
  40. +6 −0 modules/unsupported/wfs/pom.xml
  41. +21 −12 modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/WFSDataStoreFactory.java
  42. +0 −257 modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/protocol/http/DefaultHTTPProtocol.java
  43. +0 −139 modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/protocol/http/HTTPProtocol.java
  44. +0 −69 modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/protocol/http/HTTPResponse.java
  45. +26 −71 ...wfs/src/main/java/org/geotools/data/wfs/protocol/http/{AbstractHttpProtocol.java → HttpUtil.java}
  46. +0 −146 modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/protocol/http/SimpleHttpProtocol.java
  47. +45 −10 modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_1_0/DefaultWFSStrategy.java
  48. +30 −37 modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_1_0/WFS_1_1_0_Protocol.java
  49. +0 −1 modules/unsupported/wfs/src/main/java/org/geotools/wfs/protocol/ConnectionFactory.java
  50. +0 −1 modules/unsupported/wfs/src/main/java/org/geotools/wfs/protocol/DefaultConnectionFactory.java
  51. +93 −0 modules/unsupported/wfs/src/test/java/org/geotools/data/wfs/MockHttpClient.java
  52. +82 −0 modules/unsupported/wfs/src/test/java/org/geotools/data/wfs/MockHttpResponse.java
  53. +2 −2 modules/unsupported/wfs/src/test/java/org/geotools/data/wfs/WFSDataStoreFactoryTest.java
  54. +1 −1 modules/unsupported/wfs/src/test/java/org/geotools/data/wfs/v1_0_0/WFSDataStoreReadTest.java
  55. +31 −20 modules/unsupported/wfs/src/test/java/org/geotools/data/wfs/v1_1_0/DataTestSupport.java
  56. +15 −13 modules/unsupported/wfs/src/test/java/org/geotools/data/wfs/v1_1_0/GeoServerOnlineTest.java
  57. +85 −26 modules/unsupported/wfs/src/test/java/org/geotools/data/wfs/v1_1_0/HttpProtocolWrapper.java
  58. +368 −0 modules/unsupported/wfs/src/test/java/org/geotools/data/wfs/v1_1_0/TinyOwsTest.java
  59. +11 −12 modules/unsupported/wfs/src/test/java/org/geotools/data/wfs/v1_1_0/WFS_1_1_0_ProtocolTest.java
  60. +16 −0 ...ported/wfs/src/test/resources/org/geotools/data/wfs/v1_1_0/test-data/tinyows/CountFeatureById.xml
  61. +14 −0 ...wfs/src/test/resources/org/geotools/data/wfs/v1_1_0/test-data/tinyows/CountFeatureByIdRequest.xml
  62. +16 −0 ...ted/wfs/src/test/resources/org/geotools/data/wfs/v1_1_0/test-data/tinyows/CountFeaturesByBBox.xml
  63. +20 −0 .../src/test/resources/org/geotools/data/wfs/v1_1_0/test-data/tinyows/CountFeaturesByBBoxRequest.xml
  64. +16 −0 ...rted/wfs/src/test/resources/org/geotools/data/wfs/v1_1_0/test-data/tinyows/CountFirstFeatures.xml
  65. +11 −0 ...s/src/test/resources/org/geotools/data/wfs/v1_1_0/test-data/tinyows/CountFirstFeaturesRequest.xml
  66. +21 −0 ...ted/wfs/src/test/resources/org/geotools/data/wfs/v1_1_0/test-data/tinyows/DescribeFeatureType.xsd
  67. +245 −0 ...pported/wfs/src/test/resources/org/geotools/data/wfs/v1_1_0/test-data/tinyows/GetCapabilities.xml
  68. +32 −0 ...upported/wfs/src/test/resources/org/geotools/data/wfs/v1_1_0/test-data/tinyows/GetFeatureById.xml
  69. +14 −0 ...d/wfs/src/test/resources/org/geotools/data/wfs/v1_1_0/test-data/tinyows/GetFeatureByIdRequest.xml
  70. +92 −0 ...orted/wfs/src/test/resources/org/geotools/data/wfs/v1_1_0/test-data/tinyows/GetFeaturesByBBox.xml
  71. +20 −0 ...fs/src/test/resources/org/geotools/data/wfs/v1_1_0/test-data/tinyows/GetFeaturesByBBoxRequest.xml
  72. +260 −0 ...ported/wfs/src/test/resources/org/geotools/data/wfs/v1_1_0/test-data/tinyows/GetFirstFeatures.xml
  73. +11 −0 ...wfs/src/test/resources/org/geotools/data/wfs/v1_1_0/test-data/tinyows/GetFirstFeaturesRequest.xml
@@ -39,6 +39,7 @@
import org.opengis.geometry.MismatchedDimensionException;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.NoSuchAuthorityCodeException;
+import org.opengis.referencing.ReferenceIdentifier;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.TransformException;
@@ -89,7 +90,8 @@
private List<CRSEnvelope> boundingBoxes = new ArrayList<CRSEnvelope>();
/**
- * A BoundingBox containing the minimum rectangle of the map data in EPSG:4326
+ * A BoundingBox containing the minimum rectangle of the map data in CRS:84
+ * (Prior to WMS 1.3.3 this was EPSG:4326)
*/
private CRSEnvelope latLonBoundingBox = null;
@@ -794,15 +796,15 @@ public void setScaleHintMin(double scaleHintMin) {
/**
* Look up an envelope for the provided CoordianteReferenceSystem.
* <p>
- * Please note that the lookup is preformed based on the SRS Name of the provided
+ * Please note that the lookup is performed based on the SRS Name of the provided
* CRS which is assumed to be one of its identifiers.
* </p>
* This method returns the first envelope found; this may not be valid for
* sparse data sets that indicate data location using multiple envelopes for
* a provided CRS.
*
* @param crs
- * @return GeneralEnvelope matching the provided crs; or null if unavaialble.
+ * @return GeneralEnvelope matching the provided crs; or null if unavailable.
*/
public GeneralEnvelope getEnvelope(CoordinateReferenceSystem crs) {
if( crs == null ){
@@ -812,120 +814,58 @@ public GeneralEnvelope getEnvelope(CoordinateReferenceSystem crs) {
GeneralEnvelope found = (GeneralEnvelope) envelopeCache.get(crs);
if (found != null){
return found;
- }
- Collection<Object> identifiers = new ArrayList<Object>();
- identifiers.addAll( crs.getIdentifiers() );
+ }
+ Collection<String> identifiers = new ArrayList<String>();
+ for( ReferenceIdentifier identifier : crs.getIdentifiers() ){
+ String srsName = identifier.toString();
+ identifiers.add( srsName );
+ if( srsName.startsWith("EPSG:")){
+ String urn = srsName.replace("EPSG:", "urn:ogc:def:crs:EPSG::");
+ identifiers.add( urn );
+ }
+ }
if (crs == DefaultGeographicCRS.WGS84 || crs == DefaultGeographicCRS.WGS84_3D) {
identifiers.add( "CRS:84" );
}
- for (Object identifier : identifiers ) {
- String srsName = identifier.toString();
-
- CRSEnvelope tempBBox = null;
- Layer layer = this;
-
- // Locate an exact bounding box if we can
- Map<String, CRSEnvelope> boxes = layer.getBoundingBoxes(); // extents for layer and parents
+ // first pass look for an exact match
+ CRSEnvelope tempBBox = null;
+ for (String srsName : identifiers ) {
+ // Locate an exact bounding box if we can (searches all bounding boxes associated with layer)
+ Map<String, CRSEnvelope> boxes = Layer.this.getBoundingBoxes(); // extents for layer and parents
tempBBox = (CRSEnvelope) boxes.get(srsName);
-
+ if( tempBBox != null ){
+ break;
+ }
// Otherwise, locate a LatLon bounding box ... if applicable
- if (tempBBox == null && ("EPSG:4326".equals(srsName.toUpperCase()))) {
- CRSEnvelope latLonBBox = null;
-
- layer = this;
- while (latLonBBox == null && layer != null) {
- latLonBBox = layer.getLatLonBoundingBox();
- if (latLonBBox != null) {
- try {
- new GeneralEnvelope(new double[] { latLonBBox.getMinX(),
- latLonBBox.getMinY() }, new double[] { latLonBBox.getMaxX(),
- latLonBBox.getMaxY() });
- break;
- } catch (IllegalArgumentException e) {
- // TODO LOG here
- // log("Layer "+layer.getName()+" has invalid bbox declared: "+tempBbox.toString());
- latLonBBox = null;
- }
- }
- layer = layer.getParent();
- }
-
- if (latLonBBox != null) {
- tempBBox = new CRSEnvelope("CRS:84", latLonBBox.getMinX(), latLonBBox
- .getMinY(), latLonBBox.getMaxX(), latLonBBox.getMaxY());
- } else {
- tempBBox = new CRSEnvelope("CRS:84", -180, -90, 180, 90);
- // TODO could convert another bbox to latlon?
- }
+ if ("CRS:84".equals(srsName.toUpperCase()) || "EPSG:4326".equals(srsName.toUpperCase())){
+ tempBBox = Layer.this.getLatLonBoundingBox(); // checks parents
+ break;
}
-
- if (tempBBox == null) {
- // Haven't found a bbox in the requested CRS. Attempt to transform another bbox
-
- String epsg = null;
- if (getLatLonBoundingBox() != null) {
- CRSEnvelope latLonBBox = getLatLonBoundingBox();
- tempBBox = new CRSEnvelope("EPSG:4326", latLonBBox.getMinX(), latLonBBox
- .getMinY(), latLonBBox.getMaxX(), latLonBBox.getMaxY());
- epsg = "EPSG:4326";
- }
-
- if (tempBBox == null && getBoundingBoxes() != null && getBoundingBoxes().size() > 0) {
- tempBBox = (CRSEnvelope) getBoundingBoxes().values().iterator().next();
- epsg = tempBBox.getEPSGCode();
- }
-
- if (tempBBox == null) {
- continue;
- }
-
- GeneralEnvelope env = new GeneralEnvelope(new double[] { tempBBox.getMinX(),
- tempBBox.getMinY() },
+ }
+ // second pass just get a latLonBoundingox (and we will transform it)
+ if( tempBBox == null ){
+ tempBBox = Layer.this.getLatLonBoundingBox(); // checks parents
+ }
+ // TODO Attempt to figure out the valid area of the CRS and use that.
+
+ // last attempt grab the first thing (and we will transform it)
+ if (tempBBox == null && getBoundingBoxes() != null && getBoundingBoxes().size() > 0) {
+ tempBBox = (CRSEnvelope) getBoundingBoxes().values().iterator().next();
+ }
+
+ if (tempBBox != null) {
+ GeneralEnvelope env;
+ try {
+ Envelope fixed = CRS.transform( tempBBox, crs );
+ env = new GeneralEnvelope( fixed );
+ } catch (TransformException e) {
+ env = new GeneralEnvelope(new double[] { tempBBox.getMinX(),tempBBox.getMinY() },
new double[] { tempBBox.getMaxX(), tempBBox.getMaxY() });
-
- CoordinateReferenceSystem fromCRS = null;
- try {
- fromCRS = CRS.decode(epsg);
-
- ReferencedEnvelope oldEnv = new ReferencedEnvelope(env.getMinimum(0), env
- .getMaximum(0), env.getMinimum(1), env.getMaximum(1), fromCRS);
- ReferencedEnvelope newEnv = oldEnv.transform(crs, true);
-
- env = new GeneralEnvelope(new double[] { newEnv.getMinimum(0),
- newEnv.getMinimum(1) }, new double[] { newEnv.getMaximum(0),
- newEnv.getMaximum(1) });
- env.setCoordinateReferenceSystem(crs);
-
- // success!!
- envelopeCache.put(crs, env);
- return env;
-
- } catch (NoSuchAuthorityCodeException e) {
- // TODO Catch e
- } catch (FactoryException e) {
- // TODO Catch e
- } catch (MismatchedDimensionException e) {
- // TODO Catch e
- } catch (TransformException e) {
- // TODO Catch e
- }
+ env.setCoordinateReferenceSystem(crs);
}
-
- // TODO Attempt to figure out the valid area of the CRS and use that.
-
- if (tempBBox != null) {
- GeneralEnvelope env;
- try {
- Envelope fixed = CRS.transform( tempBBox, crs );
- env = new GeneralEnvelope( fixed );
- } catch (TransformException e) {
- env = new GeneralEnvelope(new double[] { tempBBox.getMinX(),tempBBox.getMinY() },
- new double[] { tempBBox.getMaxX(), tempBBox.getMaxY() });
- env.setCoordinateReferenceSystem(crs);
- }
- return env;
- }
-
+ // success!!
+ envelopeCache.put(crs, env);
+ return env;
}
return null;
}
@@ -26,6 +26,7 @@
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.HttpMethodBase;
import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
@@ -61,6 +62,8 @@
private String user;
private String password;
+
+ private boolean tryGzip = true;
public MultithreadedHttpClient() {
connectionManager = new MultiThreadedHttpConnectionManager();
@@ -117,6 +120,9 @@ public HTTPResponse post(final URL url, final InputStream postContent,
PostMethod postMethod = new PostMethod(url.toExternalForm());
postMethod.setDoAuthentication(user != null && password != null);
+ if (tryGzip) {
+ postMethod.setRequestHeader("Accept-Encoding", "gzip");
+ }
if (postContentType != null) {
postMethod.setRequestHeader("Content-type", postContentType);
}
@@ -138,7 +144,9 @@ public HTTPResponse get(final URL url) throws IOException {
GetMethod getMethod = new GetMethod(url.toExternalForm());
getMethod.setDoAuthentication(user != null && password != null);
-
+ if (tryGzip) {
+ getMethod.setRequestHeader("Accept-Encoding", "gzip");
+ }
int responseCode = client.executeMethod(getMethod);
if (200 != responseCode) {
getMethod.releaseConnection();
@@ -256,5 +264,36 @@ public InputStream getResponseStream() throws IOException {
return responseBodyAsStream;
}
+ /**
+ * @return
+ * @see org.geotools.data.ows.HTTPResponse#getResponseCharset()
+ */
+ @Override
+ public String getResponseCharset() {
+ String responseCharSet = null;
+ if (methodResponse instanceof HttpMethodBase) {
+ responseCharSet = ((HttpMethodBase) methodResponse).getResponseCharSet();
+ }
+ return responseCharSet;
+ }
+
+ }
+
+ /**
+ * @param tryGZIP
+ * @see org.geotools.data.ows.HTTPClient#setTryGzip(boolean)
+ */
+ @Override
+ public void setTryGzip(boolean tryGZIP) {
+ this.tryGzip = tryGZIP;
+ }
+
+ /**
+ * @return
+ * @see org.geotools.data.ows.HTTPClient#isTryGzip()
+ */
+ @Override
+ public boolean isTryGzip() {
+ return tryGzip;
}
}
@@ -2707,10 +2707,10 @@ public Object getValue(Element element, ElementValue[] value,
// Do not set queryable unless it is explicitly specified
String queryable = attrs.getValue("queryable");
if (queryable != null) {
- if ("1".equals(queryable)) {
+ if ("1".equals(queryable) || "true".equalsIgnoreCase(queryable)) {
layer.setQueryable(true);
- } else if ("0".equals(queryable)) {
- layer.setQueryable(new Boolean(queryable).booleanValue());
+ } else if ("0".equals(queryable) || "false".equalsIgnoreCase(queryable)) {
+ layer.setQueryable( false );
}
}
String cascaded = attrs.getValue("cascaded");
@@ -423,7 +423,8 @@ private ReferencedEnvelope flipEnvelope(ReferencedEnvelope requestEnvelope) {
double miny = requestEnvelope.getMinY();
double maxx = requestEnvelope.getMaxX();
double maxy = requestEnvelope.getMaxY();
- requestEnvelope = new ReferencedEnvelope(miny, maxy, minx, maxx, requestCRS);
+ CoordinateReferenceSystem crs = requestEnvelope.getCoordinateReferenceSystem();
+ requestEnvelope = new ReferencedEnvelope(miny, maxy, minx, maxx, requestCRS != null ? requestCRS : crs );
return requestEnvelope;
}
@@ -22,6 +22,8 @@
protected int readTimeout;
+ protected boolean tryGzip;
+
public HTTPResponse post(URL url, InputStream postContent, String postContentType)
throws IOException {
throw new UnsupportedOperationException(
@@ -71,4 +73,21 @@ public void setReadTimeout(int readTimeout) {
this.readTimeout = readTimeout;
}
+ /**
+ * @param tryGZIP
+ * @see org.geotools.data.ows.HTTPClient#setTryGzip(boolean)
+ */
+ @Override
+ public void setTryGzip(boolean tryGZIP) {
+ this.tryGzip = tryGZIP;
+ }
+
+ /**
+ * @return
+ * @see org.geotools.data.ows.HTTPClient#isTryGzip()
+ */
+ @Override
+ public boolean isTryGzip() {
+ return tryGzip;
+ }
}
@@ -71,4 +71,13 @@ public InputStream getResponseStream() throws IOException {
return new ByteArrayInputStream(response);
}
+ /**
+ * @return {@code null}
+ * @see org.geotools.data.ows.HTTPResponse#getResponseCharset()
+ */
+ @Override
+ public String getResponseCharset() {
+ return null;
+ }
+
}
Oops, something went wrong.

0 comments on commit 8e6d9e2

Please sign in to comment.