本文整理汇总了Java中com.vividsolutions.jts.geom.CoordinateSequence.getY方法的典型用法代码示例。如果您正苦于以下问题:Java CoordinateSequence.getY方法的具体用法?Java CoordinateSequence.getY怎么用?Java CoordinateSequence.getY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vividsolutions.jts.geom.CoordinateSequence
的用法示例。
在下文中一共展示了CoordinateSequence.getY方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: distanceAlong
import com.vividsolutions.jts.geom.CoordinateSequence; //导入方法依赖的package包/类
public double distanceAlong() {
CoordinateSequence cs = (this.edge.getGeometry()).getCoordinateSequence();
double dist = 0;
double x0 = cs.getX(0);
double y0 = cs.getY(0);
for (int s = 1; s < this.seg; s++) {
double x1 = cs.getX(s);
double y1 = cs.getY(s);
dist += distanceLibrary.fastDistance(y0, x0, y1, x1);
x0 = x1;
y0 = y1;
}
dist += distanceLibrary.fastDistance(y0, x0, this.y, this.x); // dist along partial
// segment
return dist;
}
示例2: distanceToEnd
import com.vividsolutions.jts.geom.CoordinateSequence; //导入方法依赖的package包/类
public double distanceToEnd() {
CoordinateSequence cs = (this.edge.getGeometry()).getCoordinateSequence();
int s = this.seg + 1;
double x0 = cs.getX(s);
double y0 = cs.getY(s);
double dist = distanceLibrary.fastDistance(y0, x0, this.y, this.x); // dist along
// partial segment
int nc = cs.size();
for (; s < nc; s++) {
double x1 = cs.getX(s);
double y1 = cs.getY(s);
dist += distanceLibrary.fastDistance(y0, x0, y1, x1);
x0 = x1;
y0 = y1;
}
return dist;
}
示例3: getLengthMultiplierFromElevation
import com.vividsolutions.jts.geom.CoordinateSequence; //导入方法依赖的package包/类
public static double getLengthMultiplierFromElevation(CoordinateSequence elev) {
double trueLength = 0;
double flatLength = 0;
double lastX = elev.getX(0);
double lastY = elev.getY(0);
for (int i = 1; i < elev.size(); ++i) {
Coordinate c = elev.getCoordinate(i);
double x = c.x - lastX;
double y = c.y - lastY;
trueLength += Math.sqrt((x * x) + (y * y));
flatLength += x;
lastX = c.x;
lastY = c.y;
}
if (flatLength == 0) { return 0; }
return trueLength / flatLength;
}
示例4: isEqual
import com.vividsolutions.jts.geom.CoordinateSequence; //导入方法依赖的package包/类
/**
* Tests for equality using all supported accessors,
* to provides test coverage for them.
*
* @param seq
* @param coords
* @return
*/
boolean isEqual(CoordinateSequence seq, Coordinate[] coords)
{
if (seq.size() != coords.length) return false;
Coordinate p = new Coordinate();
for (int i = 0; i < seq.size(); i++) {
if (! coords[i].equals(seq.getCoordinate(i))) return false;
// Ordinate named getters
if (coords[i].x != seq.getX(i)) return false;
if (coords[i].y != seq.getY(i)) return false;
// Ordinate indexed getters
if (coords[i].x != seq.getOrdinate(i, CoordinateSequence.X)) return false;
if (coords[i].y != seq.getOrdinate(i, CoordinateSequence.Y)) return false;
if (coords[i].z != seq.getOrdinate(i, CoordinateSequence.Z)) return false;
// Coordinate getter
seq.getCoordinate(i, p);
if (coords[i].x != p.x) return false;
if (coords[i].y != p.y) return false;
if (coords[i].z != p.z) return false;
}
return true;
}
示例5: hashCode
import com.vividsolutions.jts.geom.CoordinateSequence; //导入方法依赖的package包/类
@Override
public int hashCode() {
CoordinateSequence cs = ls.getCoordinateSequence();
int maxIdx = cs.size() - 1;
int x = (int) (cs.getX(0) * 1000000) + (int) (cs.getX(maxIdx) * 1000000);
int y = (int) (cs.getY(0) * 1000000) + (int) (cs.getY(maxIdx) * 1000000);
return x + y * 101149 + maxIdx * 7883;
}
示例6: findClosest
import com.vividsolutions.jts.geom.CoordinateSequence; //导入方法依赖的package包/类
/**
* DistanceToPoint.computeDistance() uses a LineSegment, which has a closestPoint method. That
* finds the true distance every time rather than once the closest segment is known, and does
* not allow for equi-rectangular projection/scaling. Here we want to compare squared distances
* to all line segments until we find the best one, then do the precise calculations.
*/
public Sample findClosest(List<Edge> edges, Coordinate pt, double xscale) {
Candidate c = new Candidate();
// track the best geometry
Candidate best = new Candidate();
for (Edge edge : edges) {
/*
* LineString.getCoordinates() uses PackedCoordinateSequence.toCoordinateArray() which
* necessarily builds new Coordinate objects.CoordinateSequence.getOrdinate() reads them
* directly.
*/
c.edge = edge;
LineString ls = (edge.getGeometry());
CoordinateSequence coordSeq = ls.getCoordinateSequence();
int numCoords = coordSeq.size();
for (int seg = 0; seg < (numCoords - 1); seg++) {
c.seg = seg;
double x0 = coordSeq.getX(seg);
double y0 = coordSeq.getY(seg);
double x1 = coordSeq.getX(seg + 1);
double y1 = coordSeq.getY(seg + 1);
// use bounding rectangle to find a lower bound on (squared) distance ?
// this would mean more squaring or roots.
c.frac = GeometryUtils.segmentFraction(x0, y0, x1, y1, pt.x, pt.y, xscale);
// project to get closest point
c.x = x0 + (c.frac * (x1 - x0));
c.y = y0 + (c.frac * (y1 - y0));
// find ersatz distance to edge (do not take root)
double dx = c.x - pt.x; // * xscale;
double dy = c.y - pt.y;
c.dist2 = (dx * dx) + (dy * dy);
// replace best segments
if (c.dist2 < best.dist2) {
best.setFrom(c);
}
} // end loop over segments
} // end loop over linestrings
// if at least one vertex was found make a sample
if (best.edge != null) {
Vertex v0 = best.edge.getFromVertex();
Vertex v1 = best.edge.getToVertex();
double d = best.distanceTo(pt);
if (d > this.searchRadiusM) { return null; }
double d0 = d + best.distanceAlong();
int t0 = (int) (d0 / 1.33);
double d1 = d + best.distanceToEnd();
int t1 = (int) (d1 / 1.33);
Sample s = new Sample(v0, t0, v1, t1);
// System.out.println(s.toString());
return s;
}
return null;
}