@Test public void testBadParamFromLrs() throws Exception { SimpleFeatureSource source = featureSource.getFeatureSource("lrssimple"); LRSGeocodeProcess process = new LRSGeocodeProcess(); SimpleFeatureCollection origional = source.getFeatures(); try { FeatureCollection result = process.execute(origional, "from_lrs_bad", "to_lrs", 1.0); Assert.fail("Expected error from bad from_lrs name"); } catch (ProcessException e) { } }
@DescribeResult(name = "result", description = "Output feature collection") public FeatureCollection execute( @DescribeParameter(name = "features", description = "Input feature collection") FeatureCollection featureCollection, @DescribeParameter( name = "from_measure_attb", description = "Attribute providing start measure of feature" ) String fromMeasureAttb, @DescribeParameter( name = "to_measure_attb", description = "Attribute providing end measure of feature" ) String toMeasureAttb, @DescribeParameter( name = "measure", description = "Measure of the point along the feature to be computed" ) Double measure) throws ProcessException { DefaultFeatureCollection results = new DefaultFeatureCollection(); try { if (featureCollection == null || featureCollection.size() == 0) { LOGGER.info("No features provided in request"); return results; } if (fromMeasureAttb == null || featureCollection.getSchema().getDescriptor(fromMeasureAttb) == null) { throw new ProcessException( "The from_measure_attb parameter was not provided or not defined in schema"); } if (toMeasureAttb == null || featureCollection.getSchema().getDescriptor(toMeasureAttb) == null) { throw new ProcessException("The to_measure_attb parameter was not provided"); } if (measure == null) { throw new ProcessException("The measure parameter was not provided"); } SimpleFeatureType targetFeatureType = createTargetFeatureType(featureCollection.getSchema()); FeatureIterator<Feature> featureIterator = null; try { featureIterator = featureCollection.features(); Feature feature = featureIterator.next(); Double featureFromMeasure = (Double) feature.getProperty(fromMeasureAttb).getValue(); Double featureToMeasure = (Double) feature.getProperty(toMeasureAttb).getValue(); LengthIndexedLine lengthIndexedLine = new LengthIndexedLine( (Geometry) feature.getDefaultGeometryProperty().getValue()); double featureLength = featureToMeasure - featureFromMeasure; double startOffset = measure - featureFromMeasure; double calcLength = ((Geometry) feature.getDefaultGeometryProperty().getValue()).getLength(); if (calcLength == 0) { LOGGER.info("Edge feature has zero length"); return results; } if (featureLength == 0) { LOGGER.info("Requested feature has zero length"); return results; } Coordinate point = lengthIndexedLine.extractPoint(startOffset * calcLength / featureLength); results.add(createTargetFeature(feature, targetFeatureType, point)); } finally { if (featureIterator != null) featureIterator.close(); } return results; } catch (ProcessException e) { throw e; } catch (Throwable e) { LOGGER.warning("Error executing method: " + e); throw new ProcessException("Error executing method: " + e, e); } }
LRSGeocodeProcess implements VectorProcess { @DescribeResult(name = "result", description = "Output feature collection") public FeatureCollection execute( @DescribeParameter(name = "features", description = "Input feature collection") FeatureCollection featureCollection, @DescribeParameter( name = "from_measure_attb", description = "Attribute providing start measure of feature" ) String fromMeasureAttb, @DescribeParameter( name = "to_measure_attb", description = "Attribute providing end measure of feature" ) String toMeasureAttb, @DescribeParameter( name = "measure", description = "Measure of the point along the feature to be computed" ) Double measure) throws ProcessException { DefaultFeatureCollection results = new DefaultFeatureCollection(); try { if (featureCollection == null || featureCollection.size() == 0) { LOGGER.info("No features provided in request"); return results; } if (fromMeasureAttb == null || featureCollection.getSchema().getDescriptor(fromMeasureAttb) == null) { throw new ProcessException( "The from_measure_attb parameter was not provided or not defined in schema"); } if (toMeasureAttb == null || featureCollection.getSchema().getDescriptor(toMeasureAttb) == null) { throw new ProcessException("The to_measure_attb parameter was not provided"); } if (measure == null) { throw new ProcessException("The measure parameter was not provided"); } SimpleFeatureType targetFeatureType = createTargetFeatureType(featureCollection.getSchema()); FeatureIterator<Feature> featureIterator = null; try { featureIterator = featureCollection.features(); Feature feature = featureIterator.next(); Double featureFromMeasure = (Double) feature.getProperty(fromMeasureAttb).getValue(); Double featureToMeasure = (Double) feature.getProperty(toMeasureAttb).getValue(); LengthIndexedLine lengthIndexedLine = new LengthIndexedLine( (Geometry) feature.getDefaultGeometryProperty().getValue()); double featureLength = featureToMeasure - featureFromMeasure; double startOffset = measure - featureFromMeasure; double calcLength = ((Geometry) feature.getDefaultGeometryProperty().getValue()).getLength(); if (calcLength == 0) { LOGGER.info("Edge feature has zero length"); return results; } if (featureLength == 0) { LOGGER.info("Requested feature has zero length"); return results; } Coordinate point = lengthIndexedLine.extractPoint(startOffset * calcLength / featureLength); results.add(createTargetFeature(feature, targetFeatureType, point)); } finally { if (featureIterator != null) featureIterator.close(); } return results; } catch (ProcessException e) { throw e; } catch (Throwable e) { LOGGER.warning("Error executing method: " + e); throw new ProcessException("Error executing method: " + e, e); } } }
LRSGeocodeProcess implements VectorProcess { @DescribeResult(name = "result", description = "Output feature collection") public FeatureCollection execute( @DescribeParameter(name = "features", description = "Input feature collection") FeatureCollection featureCollection, @DescribeParameter( name = "from_measure_attb", description = "Attribute providing start measure of feature" ) String fromMeasureAttb, @DescribeParameter( name = "to_measure_attb", description = "Attribute providing end measure of feature" ) String toMeasureAttb, @DescribeParameter( name = "measure", description = "Measure of the point along the feature to be computed" ) Double measure) throws ProcessException { DefaultFeatureCollection results = new DefaultFeatureCollection(); try { if (featureCollection == null || featureCollection.size() == 0) { LOGGER.info("No features provided in request"); return results; } if (fromMeasureAttb == null || featureCollection.getSchema().getDescriptor(fromMeasureAttb) == null) { throw new ProcessException( "The from_measure_attb parameter was not provided or not defined in schema"); } if (toMeasureAttb == null || featureCollection.getSchema().getDescriptor(toMeasureAttb) == null) { throw new ProcessException("The to_measure_attb parameter was not provided"); } if (measure == null) { throw new ProcessException("The measure parameter was not provided"); } SimpleFeatureType targetFeatureType = createTargetFeatureType(featureCollection.getSchema()); FeatureIterator<Feature> featureIterator = null; try { featureIterator = featureCollection.features(); Feature feature = featureIterator.next(); Double featureFromMeasure = (Double) feature.getProperty(fromMeasureAttb).getValue(); Double featureToMeasure = (Double) feature.getProperty(toMeasureAttb).getValue(); LengthIndexedLine lengthIndexedLine = new LengthIndexedLine( (Geometry) feature.getDefaultGeometryProperty().getValue()); double featureLength = featureToMeasure - featureFromMeasure; double startOffset = measure - featureFromMeasure; double calcLength = ((Geometry) feature.getDefaultGeometryProperty().getValue()).getLength(); if (calcLength == 0) { LOGGER.info("Edge feature has zero length"); return results; } if (featureLength == 0) { LOGGER.info("Requested feature has zero length"); return results; } Coordinate point = lengthIndexedLine.extractPoint(startOffset * calcLength / featureLength); results.add(createTargetFeature(feature, targetFeatureType, point)); } finally { if (featureIterator != null) featureIterator.close(); } return results; } catch (ProcessException e) { throw e; } catch (Throwable e) { LOGGER.warning("Error executing method: " + e); throw new ProcessException("Error executing method: " + e, e); } }  }
LRSGeocodeProcess implements VectorProcess { @DescribeResult(name = "result", description = "Output feature collection") public FeatureCollection execute( @DescribeParameter(name = "features", description = "Input feature collection") FeatureCollection featureCollection, @DescribeParameter( name = "from_measure_attb", description = "Attribute providing start measure of feature" ) String fromMeasureAttb, @DescribeParameter( name = "to_measure_attb", description = "Attribute providing end measure of feature" ) String toMeasureAttb, @DescribeParameter( name = "measure", description = "Measure of the point along the feature to be computed" ) Double measure) throws ProcessException { DefaultFeatureCollection results = new DefaultFeatureCollection(); try { if (featureCollection == null || featureCollection.size() == 0) { LOGGER.info("No features provided in request"); return results; } if (fromMeasureAttb == null || featureCollection.getSchema().getDescriptor(fromMeasureAttb) == null) { throw new ProcessException( "The from_measure_attb parameter was not provided or not defined in schema"); } if (toMeasureAttb == null || featureCollection.getSchema().getDescriptor(toMeasureAttb) == null) { throw new ProcessException("The to_measure_attb parameter was not provided"); } if (measure == null) { throw new ProcessException("The measure parameter was not provided"); } SimpleFeatureType targetFeatureType = createTargetFeatureType(featureCollection.getSchema()); FeatureIterator<Feature> featureIterator = null; try { featureIterator = featureCollection.features(); Feature feature = featureIterator.next(); Double featureFromMeasure = (Double) feature.getProperty(fromMeasureAttb).getValue(); Double featureToMeasure = (Double) feature.getProperty(toMeasureAttb).getValue(); LengthIndexedLine lengthIndexedLine = new LengthIndexedLine( (Geometry) feature.getDefaultGeometryProperty().getValue()); double featureLength = featureToMeasure - featureFromMeasure; double startOffset = measure - featureFromMeasure; double calcLength = ((Geometry) feature.getDefaultGeometryProperty().getValue()).getLength(); if (calcLength == 0) { LOGGER.info("Edge feature has zero length"); return results; } if (featureLength == 0) { LOGGER.info("Requested feature has zero length"); return results; } Coordinate point = lengthIndexedLine.extractPoint(startOffset * calcLength / featureLength); results.add(createTargetFeature(feature, targetFeatureType, point)); } finally { if (featureIterator != null) featureIterator.close(); } return results; } catch (ProcessException e) { throw e; } catch (Throwable e) { LOGGER.warning("Error executing method: " + e); throw new ProcessException("Error executing method: " + e, e); } }  @DescribeResult(name = "result", description = "Output feature collection") FeatureCollection execute(
            @DescribeParameter(name = "features", description = "Input feature collection")
                    FeatureCollection featureCollection,
            @DescribeParameter(
                        name = "from_measure_attb",
                        description = "Attribute providing start measure of feature"
                    )
                    String fromMeasureAttb,
            @DescribeParameter(
                        name = "to_measure_attb",
                        description = "Attribute providing end measure of feature"
                    )
                    String toMeasureAttb,
            @DescribeParameter(
                        name = "measure",
                        description = "Measure of the point along the feature to be computed"
                    )
                    Double measure); }
LRSGeocodeProcess implements VectorProcess { @DescribeResult(name = "result", description = "Output feature collection") public FeatureCollection execute( @DescribeParameter(name = "features", description = "Input feature collection") FeatureCollection featureCollection, @DescribeParameter( name = "from_measure_attb", description = "Attribute providing start measure of feature" ) String fromMeasureAttb, @DescribeParameter( name = "to_measure_attb", description = "Attribute providing end measure of feature" ) String toMeasureAttb, @DescribeParameter( name = "measure", description = "Measure of the point along the feature to be computed" ) Double measure) throws ProcessException { DefaultFeatureCollection results = new DefaultFeatureCollection(); try { if (featureCollection == null || featureCollection.size() == 0) { LOGGER.info("No features provided in request"); return results; } if (fromMeasureAttb == null || featureCollection.getSchema().getDescriptor(fromMeasureAttb) == null) { throw new ProcessException( "The from_measure_attb parameter was not provided or not defined in schema"); } if (toMeasureAttb == null || featureCollection.getSchema().getDescriptor(toMeasureAttb) == null) { throw new ProcessException("The to_measure_attb parameter was not provided"); } if (measure == null) { throw new ProcessException("The measure parameter was not provided"); } SimpleFeatureType targetFeatureType = createTargetFeatureType(featureCollection.getSchema()); FeatureIterator<Feature> featureIterator = null; try { featureIterator = featureCollection.features(); Feature feature = featureIterator.next(); Double featureFromMeasure = (Double) feature.getProperty(fromMeasureAttb).getValue(); Double featureToMeasure = (Double) feature.getProperty(toMeasureAttb).getValue(); LengthIndexedLine lengthIndexedLine = new LengthIndexedLine( (Geometry) feature.getDefaultGeometryProperty().getValue()); double featureLength = featureToMeasure - featureFromMeasure; double startOffset = measure - featureFromMeasure; double calcLength = ((Geometry) feature.getDefaultGeometryProperty().getValue()).getLength(); if (calcLength == 0) { LOGGER.info("Edge feature has zero length"); return results; } if (featureLength == 0) { LOGGER.info("Requested feature has zero length"); return results; } Coordinate point = lengthIndexedLine.extractPoint(startOffset * calcLength / featureLength); results.add(createTargetFeature(feature, targetFeatureType, point)); } finally { if (featureIterator != null) featureIterator.close(); } return results; } catch (ProcessException e) { throw e; } catch (Throwable e) { LOGGER.warning("Error executing method: " + e); throw new ProcessException("Error executing method: " + e, e); } }  @DescribeResult(name = "result", description = "Output feature collection") FeatureCollection execute(
            @DescribeParameter(name = "features", description = "Input feature collection")
                    FeatureCollection featureCollection,
            @DescribeParameter(
                        name = "from_measure_attb",
                        description = "Attribute providing start measure of feature"
                    )
                    String fromMeasureAttb,
            @DescribeParameter(
                        name = "to_measure_attb",
                        description = "Attribute providing end measure of feature"
                    )
                    String toMeasureAttb,
            @DescribeParameter(
                        name = "measure",
                        description = "Measure of the point along the feature to be computed"
                    )
                    Double measure);  }