Package com.vividsolutions.jts.linearref

Examples of com.vividsolutions.jts.linearref.LengthIndexedLine


            throws Exception {
        List<ProfilePoint> profilePointsList = new ArrayList<ProfilePoint>();

        LineString line = gf.createLineString(coordinates);
        double lineLength = line.getLength();
        LengthIndexedLine indexedLine = new LengthIndexedLine(line);

        double progressive = 0.0;
        Point2D point = new Point2D.Double();
        while( progressive < lineLength + step ) { // run over by a step to make sure we get the
                                                   // last coord back from the extractor
            Coordinate c = indexedLine.extractPoint(progressive);
            double value = JGTConstants.doubleNovalue;
            try {
                point.setLocation(c.x, c.y);
                double[] evaluated = coverage.evaluate(point, (double[]) null);
                value = evaluated[0];
View Full Code Here


     * @return the sub-LineString
     */
    LineString getSubLineString(LineString ls, double fraction) {
        if (fraction >= 1)
            return ls;
        LengthIndexedLine linRefLine = new LengthIndexedLine(ls);
        LineString subLine = (LineString) linRefLine.extractLine(0, fraction * ls.getLength());
        return subLine;
    }
View Full Code Here

            } finally {
                if (featureIterator != null)
                    featureIterator.close();
            }
            if (nearestFeature != null) {
                LengthIndexedLine lengthIndexedLine = new LengthIndexedLine(
                        (Geometry) nearestFeature.getDefaultGeometryProperty().getValue());
                double lineIndex = lengthIndexedLine.indexOf(nearestCoords[1]);
                double lineLength = ((Geometry) nearestFeature.getDefaultGeometryProperty()
                        .getValue()).getLength();
                Double featureFromMeasure = (Double) nearestFeature.getProperty(fromMeasureAttb)
                        .getValue();
                Double featureToMeasure = (Double) nearestFeature.getProperty(toMeasureAttb)
View Full Code Here

                                        && toMeasure >= featureToMeasure) {
                                    lineMerger.add((Geometry) feature.getDefaultGeometryProperty()
                                            .getValue());
                                } else if (fromMeasure > featureFromMeasure
                                        && toMeasure < featureToMeasure) {
                                    LengthIndexedLine lengthIndexedLine = new LengthIndexedLine(
                                            (Geometry) feature.getDefaultGeometryProperty()
                                                    .getValue());
                                    double featureLength = featureToMeasure - featureFromMeasure;
                                    double startOffset = fromMeasure - featureFromMeasure;
                                    double stopOffset = toMeasure - featureFromMeasure;
                                    double calcLength = ((Geometry) feature
                                            .getDefaultGeometryProperty().getValue()).getLength();
                                    if (calcLength == 0 || featureLength == 0)
                                        continue;
                                    Geometry extracted = lengthIndexedLine.extractLine(startOffset
                                            * calcLength / featureLength, stopOffset * calcLength
                                            / featureLength);
                                    if (!extracted.isEmpty())
                                        lineMerger.add(extracted);
                                } else if (fromMeasure > featureFromMeasure) {
                                    LengthIndexedLine lengthIndexedLine = new LengthIndexedLine(
                                            (Geometry) feature.getDefaultGeometryProperty()
                                                    .getValue());
                                    double featureLength = featureToMeasure - featureFromMeasure;
                                    double startOffset = fromMeasure - featureFromMeasure;
                                    double calcLength = ((Geometry) feature
                                            .getDefaultGeometryProperty().getValue()).getLength();
                                    if (calcLength == 0 || featureLength == 0)
                                        continue;
                                    Geometry extracted = lengthIndexedLine.extractLine(startOffset
                                            * calcLength / featureLength, calcLength);
                                    if (!extracted.isEmpty())
                                        lineMerger.add(extracted);
                                } else {
                                    LengthIndexedLine lengthIndexedLine = new LengthIndexedLine(
                                            (Geometry) feature.getDefaultGeometryProperty()
                                                    .getValue());
                                    double featureLength = featureToMeasure - featureFromMeasure;
                                    double stopOffset = toMeasure - featureFromMeasure;
                                    double calcLength = ((Geometry) feature
                                            .getDefaultGeometryProperty().getValue()).getLength();
                                    if (calcLength == 0 || featureLength == 0)
                                        continue;
                                    Geometry extracted = lengthIndexedLine.extractLine(0,
                                            stopOffset * calcLength / featureLength);
                                    if (extracted.isEmpty() || extracted.getLength() == 0.0) {
                                        LOGGER.info("Empty segment: featureFromMeasure="
                                                + featureFromMeasure + " featureToMeasure:"
                                                + featureToMeasure + " toMeasure:" + toMeasure
View Full Code Here

                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();
View Full Code Here

   * @param measure
   *            the distance along the geometry
   * @return Coordinate at 'measure' distance along the geometry
   */
  public static Coordinate locatePoint(Geometry geometry, double measure) {
    return new LengthIndexedLine(geometry).extractPoint(measure);
  }
View Full Code Here

   * @param offset
   *            the distance offset to the left (or right for negative numbers)
   * @return Point at 'measure' distance along the geometry, and offset
   */
  public static Coordinate locatePoint(Geometry geometry, double measure, double offset) {
    return new LengthIndexedLine(geometry).extractPoint(measure, offset);
  }
View Full Code Here

   * assertions are made.
   *
   * @param geometry
   */
  private void debugLRS(Geometry geometry) {
    LengthIndexedLine line = new com.vividsolutions.jts.linearref.LengthIndexedLine(geometry);
    double length = line.getEndIndex() - line.getStartIndex();
    System.out.println("Have Geometry: " + geometry);
    System.out.println("Have LengthIndexedLine: " + line);
    System.out.println("Have start index: " + line.getStartIndex());
    System.out.println("Have end index: " + line.getEndIndex());
    System.out.println("Have length: " + length);
    System.out.println("Extracting point at position 0.0: " + line.extractPoint(0.0));
    System.out.println("Extracting point at position 0.1: " + line.extractPoint(0.1));
    System.out.println("Extracting point at position 0.5: " + line.extractPoint(0.5));
    System.out.println("Extracting point at position 0.9: " + line.extractPoint(0.9));
    System.out.println("Extracting point at position 1.0: " + line.extractPoint(1.0));
    System.out.println("Extracting point at position 1.5: " + line.extractPoint(1.5));
    System.out.println("Extracting point at position 1.5 offset 0.5: " + line.extractPoint(1.5, 0.5));
    System.out.println("Extracting point at position 1.5 offset -0.5: " + line.extractPoint(1.5, -0.5));
    System.out.println("Extracting point at position " + length + ": " + line.extractPoint(length));
    System.out.println("Extracting point at position " + (length / 2) + ": " + line.extractPoint(length / 2));
    System.out.println("Extracting line from position 0.1 to 0.2: " + line.extractLine(0.1, 0.2));
    System.out.println("Extracting line from position 0.0 to " + (length / 2) + ": " + line.extractLine(0, length / 2));
    LocationIndexedLine pline = new LocationIndexedLine(geometry);
    System.out.println("Have LocationIndexedLine: " + pline);
    System.out.println("Have start index: " + pline.getStartIndex());
    System.out.println("Have end index: " + pline.getEndIndex());
    System.out.println("Extracting point at start: " + pline.extractPoint(pline.getStartIndex()));
View Full Code Here

            // simple case
            return g.getCoordinate();
        } else if (g instanceof LineString) {
            // make sure the point we return is actually on the line
            LineString line = (LineString) g;
            LengthIndexedLine lil = new LengthIndexedLine(line);
            return lil.extractPoint(line.getLength() / 2.0);
        } else {
            // return the actual centroid
            return g.getCentroid().getCoordinate();
        }
    }
View Full Code Here

public class LinearReferencingFunctions
{
  public static Geometry extractPoint(Geometry g, double index)
  {
    LengthIndexedLine ll = new LengthIndexedLine(g);
    Coordinate p = ll.extractPoint(index);
    return g.getFactory().createPoint(p);
  }
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.linearref.LengthIndexedLine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.