public GridGeometry invertGridGeometry( Map<String, Object> input, Query targetQuery, GridGeometry targetGridGeometry) throws ProcessException { Method invertGridGeometryMethod = lookupInvertGridGeometry(targetObject, this.method.getName()); if (invertGridGeometryMethod == null) { return targetGridGeometry; } try { Object[] args = buildProcessArguments(invertGridGeometryMethod, input, null, true); args[args.length - 2] = targetQuery; args[args.length - 1] = targetGridGeometry; return (GridGeometry) invertGridGeometryMethod.invoke(targetObject, args); } catch (IllegalAccessException e) { throw new ProcessException(e); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof ProcessException) { throw ((ProcessException) t); } else { throw new ProcessException(t); } } }
public Query invertQuery( Map<String, Object> input, Query targetQuery, GridGeometry targetGridGeometry) throws ProcessException { Method invertQueryMethod = lookupInvertQuery(targetObject, method.getName()); if (invertQueryMethod == null) { return targetQuery; } try { Object[] args = buildProcessArguments(invertQueryMethod, input, null, true); args[args.length - 2] = targetQuery; args[args.length - 1] = targetGridGeometry; return (Query) invertQueryMethod.invoke(targetObject, args); } catch (IllegalAccessException e) { throw new ProcessException(e); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof ProcessException) { throw ((ProcessException) t); } else { throw new ProcessException(t); } } }
@Override public GeneralParameterValue[] customizeReadParams( Map<String, Object> input, GridCoverageReader reader, GeneralParameterValue[] params) { Method customizeReadParamsMethod = lookupCustomizeReadParams(targetObject, this.method.getName()); if (customizeReadParamsMethod == null) { return params; } try { Object[] args = buildProcessArguments(customizeReadParamsMethod, input, null, true); args[args.length - 2] = reader; args[args.length - 1] = params; return (GeneralParameterValue[]) customizeReadParamsMethod.invoke(targetObject, args); } catch (IllegalAccessException e) { throw new ProcessException(e); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof ProcessException) { throw ((ProcessException) t); } else { throw new ProcessException(t); } } } }
/** * Utility method for checking if two CRS are equals * * @param crsA * @param crsB */ public static void checkCompatibleCRS( CoordinateReferenceSystem crsA, CoordinateReferenceSystem crsB) { // check if they are equal if (!CRS.equalsIgnoreMetadata(crsA, crsB)) { MathTransform mathTransform = null; try { mathTransform = CRS.findMathTransform(crsA, crsB); } catch (FactoryException e) { throw new ProcessException( "Exceptions occurred while looking for a mathTransform between the coverage's CRSs", e); } // Check if their transformation is an identity if (mathTransform != null && !mathTransform.isIdentity()) { throw new ProcessException(MISMATCHING_CRS_MESSAGE); } } } }
rasterSpaceGeometry = JTS.transform(roi, new AffineTransform2D(mt2d.createInverse())); } catch (MismatchedDimensionException e) { throw new ProcessException(e); } catch (TransformException e) { throw new ProcessException(e); } catch (NoninvertibleTransformException e) { throw new ProcessException(e);
throws ProcessException { if (coverages == null || coverages.isEmpty()) { throw new ProcessException( Errors.format(ErrorKeys.NULL_ARGUMENT_$1, "Input coverage List"));
@DescribeResult(name = "result", description = "Output feature collection") public SimpleFeatureCollection execute( @DescribeParameter(name = "first", description = "First input feature collection") SimpleFeatureCollection firstFeatures, @DescribeParameter(name = "second", description = "Second feature collection") SimpleFeatureCollection secondFeatures) throws ClassNotFoundException { if (!(firstFeatures .features() .next() .getDefaultGeometry() .getClass() .equals(secondFeatures.features().next().getDefaultGeometry().getClass()))) { throw new ProcessException("Different default geometries, cannot perform union"); } else { return new UnitedFeatureCollection(firstFeatures, secondFeatures); } }
@DescribeResult(name = "result", description = "The simplified feature collection") public SimpleFeatureCollection execute( @DescribeParameter(name = "features", description = "Input feature collection") SimpleFeatureCollection features, @DescribeParameter(name = "distance", description = "Simplification distance tolerance") double distance, @DescribeParameter( name = "preserveTopology", description = "If True, ensures that simplified features are topologically valid", defaultValue = "false" ) boolean preserveTopology) throws ProcessException { if (distance < 0) { throw new ProcessException("Invalid distance, it should be a positive number"); } return new SimplifyingFeatureCollection(features, distance, preserveTopology); }
} catch (Exception e) { LOGGER.warning("Error creating feature: " + e); throw new ProcessException("Error creating feature: " + e, e);
} catch (Exception e) { LOGGER.warning("Error creating feature: " + e); throw new ProcessException("Error creating feature: " + e, e);
} catch (Exception e) { LOGGER.warning("Error creating feature: " + e); throw new ProcessException("Error creating feature: " + e, e);
} catch (Exception e) { LOGGER.warning("Error creating feature: " + e); throw new ProcessException("Error creating feature: " + e, e);
@DescribeResult(name = "result", description = "Clipped feature collection") public SimpleFeatureCollection execute( @DescribeParameter(name = "features", description = "Input feature collection") SimpleFeatureCollection features, @DescribeParameter(name = "clip", description = "Bounds of clipping rectangle") ReferencedEnvelope clip, @DescribeParameter( name = "preserveZ", min = 0, description = "Attempt to preserve Z values from the original geometry (interpolate value for new points)" ) Boolean preserveZ) throws ProcessException { CoordinateReferenceSystem featuresCRS = features.getSchema().getCoordinateReferenceSystem(); if (featuresCRS != null && clip.getCoordinateReferenceSystem() != null && !CRS.equalsIgnoreMetadata(featuresCRS, clip.getCoordinateReferenceSystem())) { boolean lenient = true; try { clip = clip.transform(featuresCRS, lenient); } catch (TransformException e) { throw new ProcessException(e); } catch (FactoryException e) { throw new ProcessException(e); } } return new ClipProcess().execute(features, JTS.toGeometry(clip), preserveZ); } }
/** Will reproject a geometry to another CRS. */ @DescribeProcess( title = "Reproject Geometry", description = "Reprojects a given geometry into a supplied coordinate reference system." ) @DescribeResult(name = "result", description = "Reprojected geometry") public static Geometry reproject( @DescribeParameter(name = "geometry", description = "Input geometry") Geometry geometry, @DescribeParameter( name = "sourceCRS", min = 0, description = "Coordinate reference system of input geometry" ) CoordinateReferenceSystem sourceCRS, @DescribeParameter( name = "targetCRS", min = 0, description = "Target coordinate reference system to use for reprojection" ) CoordinateReferenceSystem targetCRS) { try { return JTS.transform(geometry, CRS.findMathTransform(sourceCRS, targetCRS, true)); } catch (Exception e) { throw new ProcessException("Reprojection faiiled", e); } } }
/** * Create the modified feature type. * * @param sourceFeatureType the source feature type * @return the modified feature type * @throws ProcessException errror */ private SimpleFeatureType createTargetFeatureType(FeatureType sourceFeatureType) throws ProcessException { try { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); typeBuilder.setName(sourceFeatureType.getName().getLocalPart()); typeBuilder.setNamespaceURI(sourceFeatureType.getName().getNamespaceURI()); AttributeDescriptor geomAttbType = sourceFeatureType.getGeometryDescriptor(); for (PropertyDescriptor attbType : sourceFeatureType.getDescriptors()) { if (attbType.equals(geomAttbType)) { typeBuilder.add(geomAttbType.getLocalName(), Point.class); } else { typeBuilder.add((AttributeDescriptor) attbType); } } typeBuilder.setDefaultGeometry( sourceFeatureType.getGeometryDescriptor().getLocalName()); return typeBuilder.buildFeatureType(); } catch (Exception e) { LOGGER.warning("Error creating type: " + e); throw new ProcessException("Error creating type: " + e, e); } }
/** * Create the modified feature type. * * @param sourceFeatureType the source feature type * @return the modified feature type * @throws ProcessException errror */ private SimpleFeatureType createTargetFeatureType(FeatureType sourceFeatureType) throws ProcessException { try { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); typeBuilder.setName(sourceFeatureType.getName().getLocalPart()); typeBuilder.setNamespaceURI(sourceFeatureType.getName().getNamespaceURI()); for (PropertyDescriptor attbType : sourceFeatureType.getDescriptors()) { typeBuilder.add((AttributeDescriptor) attbType); } typeBuilder.minOccurs(1).maxOccurs(1).nillable(false).add("lrs_measure", Double.class); typeBuilder.setDefaultGeometry( sourceFeatureType.getGeometryDescriptor().getLocalName()); return typeBuilder.buildFeatureType(); } catch (Exception e) { LOGGER.warning("Error creating type: " + e); throw new ProcessException("Error creating type: " + e, e); } }
} catch (Exception e) { LOGGER.warning("Error creating type: " + e); throw new ProcessException("Error creating type: " + e, e);
} catch (Exception e) { LOGGER.warning("Error creating type: " + e); throw new ProcessException("Error creating type: " + e, e);
throw new ProcessException("No kernel argument specified");
throw new ProcessException("Failed to compute statistics on feature " + zone, e);