Get the path of the line string

@param simplifyTolerance
simplify tolerance in meters
@param boundingBox
@param transform
@param lineString
557333
private Path2D getPath(double simplifyTolerance, BoundingBox boundingBox,
			ProjectionTransform transform, LineString lineString) {

		Path2D path = null;

		// Try to simplify the number of points in the LineString
		List<Point> lineStringPoints = simplifyPoints(simplifyTolerance,
				lineString.getPoints());

		for (Point point : lineStringPoints) {

			Point projectedPoint = transform.transform(point);

			float x = TileBoundingBoxUtils.getXPixel(tileWidth, boundingBox,
					projectedPoint.getX());
			float y = TileBoundingBoxUtils.getYPixel(tileHeight, boundingBox,
					projectedPoint.getY());

			if (path == null) {
				path = new Path2D.Double();
				path.moveTo(x, y);
			} else {
				path.lineTo(x, y);
			}

		}

		return path;
	}
1183112
function findLineInRange(sdpLines, startLine, endLine, prefix, substr) {
            var realEndLine = endLine !== -1 ? endLine : sdpLines.length;
            for (var i = startLine; i < realEndLine; ++i) {
                if (sdpLines[i].indexOf(prefix) === 0) {
                    if (!substr ||
                        sdpLines[i].toLowerCase().indexOf(substr.toLowerCase()) !== -1) {
                        return i;
                    }
                }
            }
            return null;
        }
583746
public static List<LineString> getSectionsFromCoordinates( List<Coordinate> coordinates, double width ) {

        if (coordinates.size() < 3) {
            throw new IllegalArgumentException("This method works only on lines with at least 3 coordinates.");
        }
        double halfWidth = width / 2.0;
        List<LineString> linesList = new ArrayList<LineString>();
        // first section
        Coordinate centerCoordinate = coordinates.get(0);
        LineSegment l1 = new LineSegment(centerCoordinate, coordinates.get(1));
        Coordinate leftCoordinate = l1.pointAlongOffset(0.0, halfWidth);
        Coordinate rightCoordinate = l1.pointAlongOffset(0.0, -halfWidth);
        LineString lineString = geomFactory.createLineString(new Coordinate[]{leftCoordinate, centerCoordinate, rightCoordinate});
        linesList.add(lineString);

        for( int i = 1; i < coordinates.size() - 1; i++ ) {
            Coordinate previous = coordinates.get(i - 1);
            Coordinate current = coordinates.get(i);
            Coordinate after = coordinates.get(i + 1);

            double firstAngle = azimuth(current, previous);
            double secondAngle = azimuth(current, after);

            double a1 = min(firstAngle, secondAngle);
            double a2 = max(firstAngle, secondAngle);

            double centerAngle = a1 + (a2 - a1) / 2.0;

            AffineTransformation rotationInstance = AffineTransformation.rotationInstance(-toRadians(centerAngle), current.x,
                    current.y);

            LineString vertical = geomFactory.createLineString(new Coordinate[]{new Coordinate(current.x, current.y + halfWidth),
                    current, new Coordinate(current.x, current.y - halfWidth)});
            Geometry transformed = rotationInstance.transform(vertical);
            linesList.add((LineString) transformed);
        }

        // last section
        centerCoordinate = coordinates.get(coordinates.size() - 1);
        LineSegment l2 = new LineSegment(centerCoordinate, coordinates.get(coordinates.size() - 2));
        leftCoordinate = l2.pointAlongOffset(0.0, halfWidth);
        rightCoordinate = l2.pointAlongOffset(0.0, -halfWidth);
        lineString = geomFactory.createLineString(new Coordinate[]{leftCoordinate, centerCoordinate, rightCoordinate});
        linesList.add(lineString);

        return linesList;
    }
1235196
public static <T> String path(TreeDef.Parented<T> treeDef, T node, Function<? super T, String> toString, String delimiter) {
		List<T> toRoot = toRoot(treeDef, node);
		ListIterator<T> iterator = toRoot.listIterator(toRoot.size());
		StringBuilder builder = new StringBuilder();
		while (iterator.hasPrevious()) {
			T segment = iterator.previous();
			// add the node
			builder.append(toString.apply(segment));
			// add the separator if it makes sense
			if (iterator.hasPrevious()) {
				builder.append(delimiter);
			}
		}
		return builder.toString();
	}
234808
public static void lineStringOffSetCurve(ArrayList<LineString> list, LineString lineString, double offset, BufferParameters bufferParameters) {
        list.add(lineString.getFactory().createLineString(new OffsetCurveBuilder(lineString.getPrecisionModel(), bufferParameters).getOffsetCurve(lineString.getCoordinates(), offset)));
    }
1360271
private static MultiLineString splitMultiLineStringWithPoint(MultiLineString multiLineString, Point pointToSplit, double tolerance) {
        ArrayList<LineString> linestrings = new ArrayList<LineString>();
        boolean notChanged = true;
        int nb = multiLineString.getNumGeometries();
        for (int i = 0; i < nb; i++) {
            LineString subGeom = (LineString) multiLineString.getGeometryN(i);
            LineString[] result = splitLineStringWithPoint(subGeom, pointToSplit, tolerance);
            if (result != null) {
                Collections.addAll(linestrings, result);
                notChanged = false;
            } else {
                linestrings.add(subGeom);
            }
        }
        if (!notChanged) {
            return FACTORY.createMultiLineString(linestrings.toArray(new LineString[0]));
        }
        return null;
    }
819044
def parse_transform(transform_str):
    """"""
    if not transform_str:
        return np.identity(3)
    elif not isinstance(transform_str, str):
        raise TypeError('Must provide a string to parse')

    total_transform = np.identity(3)
    transform_substrs = transform_str.split(')')[:-1]  # Skip the last element, because it should be empty
    for substr in transform_substrs:
        total_transform = total_transform.dot(_parse_transform_substr(substr))

    return total_transform
793697
public LineString extractPart(double startDistance, double endDistance) {
        LineString result = new LineString();

        for (int i = 0; i < this.segments.size(); startDistance -= this.segments.get(i).length(), endDistance -= this.segments.get(i).length(), i++) {
            LineSegment segment = this.segments.get(i);

            // Skip first segments that we don't need
            double length = segment.length();
            if (length < startDistance) {
                continue;
            }

            Point startPoint = null, endPoint = null;
            if (startDistance >= 0) {
                // This will be our starting point
                startPoint = segment.pointAlongLineSegment(startDistance);
            }
            if (endDistance < length) {
                // this will be our ending point
                endPoint = segment.pointAlongLineSegment(endDistance);
            }

            if (startPoint != null && endPoint == null) {
                // This ist the starting segment, end will come in a later segment
                result.segments.add(new LineSegment(startPoint, segment.end));
            } else if (startPoint == null && endPoint == null) {
                // Center segment between start and end segment, add completely
                result.segments.add(segment);
            } else if (startPoint == null && endPoint != null) {
                // End segment, start was in earlier segment
                result.segments.add(new LineSegment(segment.start, endPoint));
            } else if (startPoint != null && endPoint != null) {
                // Start and end on same segment
                result.segments.add(new LineSegment(startPoint, endPoint));
            }

            if (endPoint != null)
                break;
        }

        return result;
    }
166268
public JTSLineStringExpression<?> exteriorRing() {
        if (exteriorRing == null) {
            exteriorRing = JTSGeometryExpressions.lineStringOperation(SpatialOps.EXTERIOR_RING, mixin);
        }
        return exteriorRing;
    }
740787
public void lineTo(float x, float y) {
        PathLineOperation operation = new PathLineOperation();
        operation.x = x;
        operation.y = y;
        operations.add(operation);

        LineShadowOperation shadowOperation = new LineShadowOperation(operation, endX, endY);

        // The previous endX and endY is the starting point for this shadow operation.
        addShadowCompatOperation(
                shadowOperation,
                ANGLE_UP + shadowOperation.getAngle(),
                ANGLE_UP + shadowOperation.getAngle());

        endX = x;
        endY = y;
    }
742941
public String getPath(Function<? super T, String> toString, String delimiter) {
		return TreeQuery.path(treeDef(), this, node -> toString.apply(node.getContent()), delimiter);
	}
1341317
private static Path processPoly(Element element, StringTokenizer tokens) throws ParsingException {
		int count = 0;
		
		ArrayList pts = new ArrayList();
		boolean moved = false;
		boolean reasonToBePath = false;
		Path path = null;
		
		while (tokens.hasMoreTokens()) {
			try {
				String nextToken = tokens.nextToken();
				if (nextToken.equals("L")) {
					float x = Float.parseFloat(tokens.nextToken());
					float y = Float.parseFloat(tokens.nextToken());
					path.lineTo(x,y);
					continue;
				}
				if (nextToken.equals("z")) {
					path.close();
					continue;
				}
				if (nextToken.equals("M")) {
					if (!moved) {
						moved = true;
						float x = Float.parseFloat(tokens.nextToken());
						float y = Float.parseFloat(tokens.nextToken());
						path = new Path(x,y);
						continue;
					}
	
					reasonToBePath = true;
					float x = Float.parseFloat(tokens.nextToken());
					float y = Float.parseFloat(tokens.nextToken());
					path.startHole(x,y);
					
					continue;
				}
				if (nextToken.equals("C")) {
					reasonToBePath = true;
					float cx1 = Float.parseFloat(tokens.nextToken());
					float cy1 = Float.parseFloat(tokens.nextToken());
					float cx2 = Float.parseFloat(tokens.nextToken());
					float cy2 = Float.parseFloat(tokens.nextToken());
					float x = Float.parseFloat(tokens.nextToken());
					float y = Float.parseFloat(tokens.nextToken());
					path.curveTo(x,y,cx1,cy1,cx2,cy2);
					continue;
				}
			} catch (NumberFormatException e) {
				throw new ParsingException(element.getAttribute("id"), "Invalid token in points list", e);
			}
		}
		
		if (!reasonToBePath) {
			return null;
		}
		
		return path;
	}
1123757
private void simplify(PatternRule rule, List<String> xmlLines) {
    List<Integer> linesToRemove = new ArrayList<>();
    String currentRuleId = null;
    Pattern pattern = Pattern.compile(".*id=[\"'](.*?)[\"'].*");
    String expectedSubId = rule.getSubId();
    int lineCount = 0;
    int subRuleCount = 0;
    int removedCount = 0;
    boolean inRuleGroup = false;
    String newRegex = null;
    boolean inAntiPattern = false;
    for (lineCount = 0; lineCount < xmlLines.size(); lineCount++) {
    //for (String xmlLine : xmlLines) {
      String xmlLine = xmlLines.get(lineCount);
      if (xmlLine.contains("<rulegroup")) {
        subRuleCount = 0;
        inRuleGroup = true;
      } else if (xmlLine.contains("</rulegroup>")) {
        subRuleCount = 0;
        inRuleGroup = false;
      } else if ((xmlLine.contains("<rule ")||xmlLine.contains("<rule>")) && inRuleGroup) {
        subRuleCount++;
      }
      Matcher m = pattern.matcher(xmlLine);
      if (m.matches()) {
        currentRuleId = m.group(1);
      }
      if (currentRuleId != null && !currentRuleId.equals(rule.getId())) {
        continue;
      }
      if (!inRuleGroup) {
        subRuleCount = 1;
      }
      if (!expectedSubId.equals("0") && !expectedSubId.equals(String.valueOf(subRuleCount))) {
        continue;
      }
      if (xmlLine.matches(".*<antipattern.*")) {
        inAntiPattern = true;
      }
      if (inAntiPattern) {
        continue;
      }
      if (xmlLine.matches(".*</antipattern.*")) {
        inAntiPattern = false;
        continue;
      }
      if (xmlLine.matches(".*<(token|pattern).*") || xmlLine.matches("\\s*</?marker>.*")) {
        linesToRemove.add(lineCount);
      }
      if (xmlLine.matches(".*</pattern.*")) {
        linesToRemove.add(lineCount);
        int lastTokenIndent = xmlLine.indexOf("<");
        newRegex = Strings.repeat(" ", lastTokenIndent) + getRegex(rule);
      }
    }
    Collections.reverse(linesToRemove); // start from end, as we need to remove items
    for (Integer s : linesToRemove) {
      xmlLines.remove(s.intValue());
      removedCount++;
    }
    if (removedCount == 0) {
      System.err.println("No line removed: " + rule + "[" + expectedSubId + "]");
    } else {
      xmlLines.add(linesToRemove.get(linesToRemove.size()-1), newRegex);
      touchedRulesCount++;
    }
  }
1259844
public static Geometry drapeMultiLineString(MultiLineString lines, Geometry triangles, STRtree sTRtree) {
        GeometryFactory factory = lines.getFactory();         
        //Split the triangles in lines to perform all intersections
        Geometry triangleLines = LinearComponentExtracter.getGeometry(triangles, true);
        int nbLines = lines.getNumGeometries();
        LineString[] lineStrings = new LineString[nbLines];
        for (int i = 0; i < nbLines; i++) {
            lineStrings[i] = (LineString) lineMerge(lines.getGeometryN(i).difference(triangleLines), factory);
        }
        Geometry diffExt = factory.createMultiLineString(lineStrings);
        CoordinateSequenceFilter drapeFilter = new DrapeFilter(sTRtree);
        diffExt.apply(drapeFilter);
        return diffExt;
    }
190869
public void process(PairLineNorm line, AssociatedPair point) {

		// t0 = (F*x) cross l'
		GeometryMath_F64.mult(F,point.p1,Fx);
		GeometryMath_F64.cross(Fx,line.getL2(),t0);
		// t1 = x' cross ((f*x) cross l')
		GeometryMath_F64.cross(point.p2, t0, t1);
		// t0 = x' cross e'
		GeometryMath_F64.cross(point.p2,e2,t0);

		double top = GeometryMath_F64.dot(t0,t1);
		double bottom = t0.normSq()*(line.l1.x*point.p1.x + line.l1.y*point.p1.y + line.l1.z);

		// e' * l^T
		GeometryMath_F64.outerProd(e2, line.l1, el);
		// cross(l')*F
		GeometryMath_F64.multCrossA(line.l2, F, lf);

		CommonOps_DDRM.add(lf,top/bottom,el,H);

		// pick a good scale and sign for H
		adjust.adjust(H, point);
	}
406405
private Geometry getArealGeometryFromLinearRing(LinearRing ring) {
        if (ring.isSimple()) {
            return ring.getFactory().createMultiPolygon(new Polygon[]{
                ring.getFactory().createPolygon(ring, EMPTY_RING_ARRAY)
            });
        } else {
            // Node input LinearRing and extract unique segments
            Set<LineString> lines = nodeLineString(ring.getCoordinates(), ring.getFactory());
            lines = getSegments(lines);

            // Polygonize the line network
            Polygonizer polygonizer = new Polygonizer();
            polygonizer.add(lines);

            // Computes intersections to determine the status of each polygon
            Collection<Geometry> geoms = new ArrayList();
            for (Object object : polygonizer.getPolygons()) {
                Polygon polygon = (Polygon) object;
                Coordinate p = polygon.getInteriorPoint().getCoordinate();
                int location = RayCrossingCounter.locatePointInRing(p, ring.getCoordinateSequence());
                if (location == Location.INTERIOR) {
                    geoms.add(polygon);
                }
            }
            Geometry unionPoly = UnaryUnionOp.union(geoms);
            Geometry unionLines = UnaryUnionOp.union(lines).difference(unionPoly.getBoundary());
            geoms.clear();
            decompose(unionPoly, geoms);
            decompose(unionLines, geoms);
            return ring.getFactory().buildGeometry(geoms);
        }
    }
1086082
private <L extends UriBaseListener> void analyzePathInternal(final String input, L listener) {
		pathSegmentIndex = -1;
		walker.walk(listener, preparePath(input).value0);
	}