当前位置: 首页>>代码示例>>Java>>正文


Java LineString.getCoordinates方法代码示例

本文整理汇总了Java中com.vividsolutions.jts.geom.LineString.getCoordinates方法的典型用法代码示例。如果您正苦于以下问题:Java LineString.getCoordinates方法的具体用法?Java LineString.getCoordinates怎么用?Java LineString.getCoordinates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vividsolutions.jts.geom.LineString的用法示例。


在下文中一共展示了LineString.getCoordinates方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: split

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
public static List<LineString> split(LineString given, int maxPoint) {
    List<LineString> result = newArrayList();
    Coordinate[] coordinates = given.getCoordinates();
    int current = 0;
    while (current < coordinates.length) {
        int end = current + maxPoint - 1;
        if (coordinates.length - end < 2) {
            result.add(gf.createLineString(Arrays.copyOfRange(coordinates, current, coordinates.length)));
            return result;
        }
        else {
            result.add(gf.createLineString(Arrays.copyOfRange(coordinates, current, end + 1)));
            current = end;
        }
    }
    throw new IllegalStateException("Unexpected");
}
 
开发者ID:Mappy,项目名称:fpm,代码行数:18,代码来源:LongLineSplitter.java

示例2: visitInteriorRing

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
private void visitInteriorRing(LineString ring, PlanarGraph graph) {
    Coordinate[] pts = ring.getCoordinates();
    Coordinate pt0 = pts[0];
    /**
     * Find first point in coord list different to initial point.
     * Need special check since the first point may be repeated.
     */
    Coordinate pt1 = findDifferentPoint(pts, pt0);
    Edge e = graph.findEdgeInSameDirection(pt0, pt1);
    DirectedEdge de = (DirectedEdge) graph.findEdgeEnd(e);
    DirectedEdge intDe = null;
    if (de.getLabel().getLocation(0, Position.RIGHT) == Location.INTERIOR) {
        intDe = de;
    } else if (de.getSym().getLabel().getLocation(0, Position.RIGHT) == Location.INTERIOR) {
        intDe = de.getSym();
    }
    Assert.isTrue(intDe != null, "unable to find dirEdge with Interior on RHS");

    this.visitLinkedDirectedEdges(intDe);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:21,代码来源:ConnectedInteriorTester.java

示例3: ajouterOrientation

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
/**
 * Ajout des orientations et des longueurs à la liste des orientations et des poids.
 * @param contour LineString correspond aux contours interieur ou extérieur du polygone.
 */
private void ajouterOrientation(LineString contour){
	double orientation,lg;
	Coordinate[] coord = contour.getCoordinates();
	Coordinate c1=coord[0], c2;
	for(int i=1; i<coord.length; i++) {
		c2=coord[i];
		//calcul de l'orientation à PI/2 pres entre c1 et c2
		if (c1.x==c2.x) orientation=0.0; else orientation=Math.atan( ((c1.y-c2.y)/(c1.x-c2.x)) );
		if (orientation<0) orientation+=0.5*Math.PI;
		if (logger.isDebugEnabled()) logger.debug("   orientation (en deg): "+orientation*180/Math.PI);
		listeOrientations.add(orientation);
		// Calcul de la longueur de l'arète
		lg=c1.distance(c2);
		listePoids.add(lg);
		//et au suivant
		c1=c2;
	}
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:23,代码来源:MesureOrientationFeuille.java

示例4: computeMinDistance

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
private void computeMinDistance(LineString line, Point pt,
                                GeometryLocation[] locGeom) {
    if (line.getEnvelopeInternal().distance(pt.getEnvelopeInternal())
            > this.minDistance) {
        return;
    }
    Coordinate[] coord0 = line.getCoordinates();
    Coordinate coord = pt.getCoordinate();
    // brute force approach!
    for (int i = 0; i < coord0.length - 1; i++) {
        double dist = CGAlgorithms.distancePointLine(
                coord, coord0[i], coord0[i + 1]);
        if (dist < this.minDistance) {
            this.minDistance = dist;
            LineSegment seg = new LineSegment(coord0[i], coord0[i + 1]);
            Coordinate segClosestPoint = seg.closestPoint(coord);
            locGeom[0] = new GeometryLocation(line, i, segClosestPoint);
            locGeom[1] = new GeometryLocation(pt, 0, coord);
        }
        if (this.minDistance <= this.terminateDistance) {
            return;
        }
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:25,代码来源:DistanceOp.java

示例5: locate

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
private int locate(Coordinate p, LineString l) {
    // bounding-box check
    if (!l.getEnvelopeInternal().intersects(p)) {
        return Location.EXTERIOR;
    }

    Coordinate[] pt = l.getCoordinates();
    if (!l.isClosed()) {
        if (p.equals(pt[0])
                || p.equals(pt[pt.length - 1])) {
            return Location.BOUNDARY;
        }
    }
    if (CGAlgorithms.isOnLine(p, pt)) {
        return Location.INTERIOR;
    }
    return Location.EXTERIOR;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:19,代码来源:PointLocator.java

示例6: calculateLengthMeterFromWGS84LineStringAndoyer

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
/**
 * Calculates the Length of a linestring in meters with the method from Andoyer
 * @param geometry
 * @return
 */
public static double calculateLengthMeterFromWGS84LineStringAndoyer(LineString geometry) {
	
	Coordinate coords[] = geometry.getCoordinates();
	double length = 0;
	for (int i = 1; i < coords.length; i++) {
		length += distanceAndoyer(coords[i - 1], coords[i]);
	}
	return length;
}
 
开发者ID:graphium-project,项目名称:graphium,代码行数:15,代码来源:GeometryUtils.java

示例7: smooth

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
/**
 * Creates a new {@code LineString} which is a smoothed version of 
 * the input {@code LineString}.
 * 
 * @param ls the input {@code LineString}
 * 
 * @param alpha a value between 0 and 1 (inclusive) specifying the tightness
 *        of fit of the smoothed boundary (0 is loose)
 * 
 * @return the smoothed {@code LineString}
 */
LineString smooth(LineString ls, double alpha) {
    Coordinate[] coords = ls.getCoordinates();
    
    Coordinate[][] controlPoints = getLineControlPoints(coords, alpha);
    
    final int N = coords.length;
    List<Coordinate> smoothCoords = new ArrayList<Coordinate>();
    double dist;
    for (int i = 0; i < N - 1; i++) {
        dist = coords[i].distance(coords[i+1]);
        if (dist < control.getMinLength()) {
            // segment too short - just copy input coordinate
            smoothCoords.add(new Coordinate(coords[i]));
            
        } else {
            int smoothN = control.getNumVertices(dist);
            Coordinate[] segment = cubicBezier(
                    coords[i], coords[i+1],
                    controlPoints[i][1], controlPoints[i+1][0],
                    smoothN);
        
            int copyN = i < N - 1 ? segment.length - 1 : segment.length;
            for (int k = 0; k < copyN; k++) {
                smoothCoords.add(segment[k]);
            }
        }
    }
    smoothCoords.add(coords[N - 1]);

    return geomFactory.createLineString(smoothCoords.toArray(new Coordinate[0]));
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:43,代码来源:GeometrySmoother.java

示例8: reverse

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
private static LineString reverse(LineString line) {
    Coordinate[] pts = line.getCoordinates();
    Coordinate[] revPts = new Coordinate[pts.length];
    int len = pts.length;
    for (int i = 0; i < len; i++) {
        revPts[len - 1 - i] = new Coordinate(pts[i]);
    }
    return line.getFactory().createLineString(revPts);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:10,代码来源:LineSequencer.java

示例9: computeDistance

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
public static void computeDistance(LineString line, Coordinate pt, PointPairDistance ptDist) {
    Coordinate[] coords = line.getCoordinates();
    for (int i = 0; i < coords.length - 1; i++) {
        tempSegment.setCoordinates(coords[i], coords[i + 1]);
        // this is somewhat inefficient - could do better
        Coordinate closestPt = tempSegment.closestPoint(pt);
        ptDist.setMinimum(closestPt, pt);
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:10,代码来源:DistanceToPointFinder.java

示例10: computeMinDistanceLineLine

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
private void computeMinDistanceLineLine(LineString line0, LineString line1,
                                        boolean flip) {
    Coordinate[] coord0 = line0.getCoordinates();
    Coordinate[] coord1 = line1.getCoordinates();
    // brute force approach!
    for (int i = 0; i < coord0.length - 1; i++) {
        for (int j = 0; j < coord1.length - 1; j++) {
            double dist = CGAlgorithms3D.distanceSegmentSegment(coord0[i],
                    coord0[i + 1], coord1[j], coord1[j + 1]);
            if (dist < this.minDistance) {
                this.minDistance = dist;
                // TODO: compute closest pts in 3D
                LineSegment seg0 = new LineSegment(coord0[i], coord0[i + 1]);
                LineSegment seg1 = new LineSegment(coord1[j], coord1[j + 1]);
                Coordinate[] closestPt = seg0.closestPoints(seg1);
                this.updateDistance(dist,
                        new GeometryLocation(line0, i, closestPt[0]),
                        new GeometryLocation(line1, j, closestPt[1]),
                        flip
                );
            }
            if (this.isDone) {
                return;
            }
        }
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:28,代码来源:Distance3DOp.java

示例11: init

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
private void init(Geometry geom) {
    List lines = LinearComponentExtracter.getLines(geom);
    for (Object line1 : lines) {
        LineString line = (LineString) line1;
        Coordinate[] pts = line.getCoordinates();
        this.addLine(pts);
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:9,代码来源:IndexedPointInAreaLocator.java

示例12: extractSegmentStrings

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
/**
 * Extracts all linear components from a given {@link Geometry}
 * to {@link SegmentString}s.
 * The SegmentString data item is set to be the source Geometry.
 *
 * @param geom the geometry to extract from
 * @return a List of SegmentStrings
 */
public static List extractSegmentStrings(Geometry geom) {
    List segStr = new ArrayList();
    List lines = LinearComponentExtracter.getLines(geom);
    for (Object line1 : lines) {
        LineString line = (LineString) line1;
        Coordinate[] pts = line.getCoordinates();
        segStr.add(new NodedSegmentString(pts, geom));
    }
    return segStr;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:19,代码来源:SegmentStringUtil.java

示例13: densification

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
public static LineString densification(LineString ls, double pas) {

    // coordonnees de la ligne initiale
    Coordinate[] coords = ls.getCoordinates();

    // table des coordonnees densifiees
    int nbPoints = (int) (ls.getLength() / pas);
    Coordinate[] coordsDens = new Coordinate[nbPoints + 1];

    // remplissage
    int iDens = 0;
    double dist = 0.0, angle = 0.0, longueur;
    for (int i = 0; i < coords.length - 1; i++) {
      Coordinate coord0 = coords[i], coord1 = coords[i + 1];

      longueur = coord0.distance(coord1);
      if (dist <= longueur)
        angle = Math.atan2(coord1.y - coord0.y, coord1.x - coord0.x);

      while (dist <= longueur) {

        // ajouter point a ligne densifiee
        coordsDens[iDens] = new Coordinate(coord0.x + dist * Math.cos(angle),
            coord0.y + dist * Math.sin(angle));

        dist += pas;
        iDens++;
      }
      dist -= longueur;
    }

    // le dernier point
    coordsDens[nbPoints] = coords[coords.length - 1];

    return new GeometryFactory().createLineString(coordsDens);
  }
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:37,代码来源:LineDensification.java

示例14: rotation

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
public static LineString rotation(LineString ls, Coordinate c, double angle) {
  double cos = Math.cos(angle), sin = Math.sin(angle);

  Coordinate[] coord = ls.getCoordinates();
  Coordinate[] coord_ = new Coordinate[coord.length];
  for (int i = 0; i < coord.length; i++) {
    double x = coord[i].x, y = coord[i].y;
    coord_[i] = new Coordinate(c.x + cos * (x - c.x) - sin * (y - c.y),
        c.y + sin * (x - c.x) + cos * (y - c.y));
  }
  return new GeometryFactory().createLineString(coord_);
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:13,代码来源:CommonAlgorithms.java

示例15: ajouterContribution

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
/**
 * Calcule les contributions de chaque mur a chaque orientation testee.
 * Chaque côté contribue proportionellement à sa longueur et à son écart à l'orientation testés
 * @param ls ligne évaluée
 */
private void ajouterContribution(LineString ls){
	double orientation, lg;
	
	//parcours des cotes pour calculer la contribution de chacun
	Coordinate[] coord=ls.getCoordinates();
	Coordinate c1=coord[0], c2;
	double pasOrientation = Math.PI*0.5/NB_ORIENTATIONS_TESTEES;
	double orientationTestee = 0;
	int index = 0;
	while(orientationTestee< 0.5*Math.PI){
		for(int i=1; i<coord.length; i++) {
			c2=coord[i];

			if (logger.isDebugEnabled()) logger.debug("contribution de cote ("+c1+", "+c2+")");

			//calcul de l'orientation à PI/2 pres entre c1 et c2
			if (c1.x==c2.x) orientation=0.0; else orientation=Math.atan( ((c1.y-c2.y)/(c1.x-c2.x)) );
			if (orientation<0) orientation+=0.5*Math.PI;
			if (logger.isDebugEnabled()) logger.debug("   orientation (en deg): "+orientation*180/Math.PI);

			// Calcul de l'angle entre l'arète courante et l'angle auquel on est en train d'associer un poids
			double alpha = Math.abs(orientationTestee-orientation);
			if(alpha>(Math.PI/4)) alpha = (0.5*Math.PI)-alpha;

			// Calcul de la longueur de l'arète
			lg=c1.distance(c2);
			
			// Si alpha est plus petit que l'angleContibutif l'arète est prise en compte pour l'orientation testée 
			if(alpha < ANGLE_CONTRIBUTIF){
				contributionsCotesOrientation[index] += ((ANGLE_CONTRIBUTIF-alpha)/ANGLE_CONTRIBUTIF)* lg;
			}
			//et au suivant
			c1=c2;
		}
		index++;
		orientationTestee += pasOrientation;
	}
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:44,代码来源:MesureOrientation.java


注:本文中的com.vividsolutions.jts.geom.LineString.getCoordinates方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。