Skip to content

Commit

Permalink
deegree#414 - added check if geometries are in the valid domain of th…
Browse files Browse the repository at this point in the history
…e crs
  • Loading branch information
lgoltz committed Apr 28, 2016
1 parent 1204246 commit 0530780
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@
import org.deegree.filter.Filters;
import org.deegree.filter.IdFilter;
import org.deegree.filter.OperatorFilter;
import org.deegree.geometry.Envelope;
import org.deegree.geometry.Geometry;
import org.deegree.geometry.GeometryFactory;
import org.deegree.geometry.SimpleGeometryFactory;
import org.deegree.geometry.validation.CoordinateValidityInspector;
import org.deegree.gml.GMLInputFactory;
import org.deegree.gml.GMLStreamReader;
Expand Down Expand Up @@ -155,6 +157,8 @@ class TransactionHandler {

private static final Logger LOG = LoggerFactory.getLogger( TransactionHandler.class );

private static final SimpleGeometryFactory GEOM_FACTORY = new SimpleGeometryFactory();

private final WebFeatureService master;

private final WfsFeatureStoreManager service;
Expand Down Expand Up @@ -937,6 +941,7 @@ private void evaluateSrsNameForFeature( Feature feature, List<ICRS> queryCRS, St
for ( Geometry geometry : geometries ) {
ICRS crs = geometry.getCoordinateSystem();
evaluateSrsName( crs, queryCRS, handle );
evaluateValidDomain( crs, geometry, handle );
}
}

Expand All @@ -951,6 +956,24 @@ private void evaluateSrsName( ICRS crs, List<ICRS> supportedCrs, String handle )
}
}

private void evaluateValidDomain( ICRS crs, Geometry geometry, String handle )
throws OWSException {
double[] validDomain = crs.getValidDomain();
if ( validDomain == null ) {
LOG.warn( "Valid domain of crs {} is not available. Check if geometry is inside the valid "
+ "domain not possible. The check is skipped and insert processed.", crs.getAlias() );
return;
}
Envelope validDomainBbox = GEOM_FACTORY.createEnvelope( validDomain[0], validDomain[1], validDomain[2],
validDomain[3], crs );
if ( !geometry.isWithin( validDomainBbox ) ) {
String message = "At least one geometry is not in the valid domain of the srs.";
if ( handle == null || "".equals( handle ) )
handle = "Transaction";
throw new OWSException( message, OWSException.OPERATION_PROCESSING_FAILED, handle );
}
}

private boolean isCrsSupported( ICRS crs, List<ICRS> supportedCrs )
throws OWSException {
if ( crs != null && supportedCrs != null )
Expand Down

0 comments on commit 0530780

Please sign in to comment.