本文整理汇总了Java中com.vividsolutions.jts.geom.CoordinateSequence.getOrdinate方法的典型用法代码示例。如果您正苦于以下问题:Java CoordinateSequence.getOrdinate方法的具体用法?Java CoordinateSequence.getOrdinate怎么用?Java CoordinateSequence.getOrdinate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vividsolutions.jts.geom.CoordinateSequence
的用法示例。
在下文中一共展示了CoordinateSequence.getOrdinate方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyZValues
import com.vividsolutions.jts.geom.CoordinateSequence; //导入方法依赖的package包/类
private void applyZValues(CoordinateSequence cs, int idx,
CoordinateSequence csOrig, int origIdx) {
double lx1 = cs.getOrdinate(idx, 0);
double ly1 = cs.getOrdinate(idx, 1);
double lz1;
double ox1 = csOrig.getOrdinate(origIdx, 0);
double oy1 = csOrig.getOrdinate(origIdx, 1);
double oz1 = csOrig.getOrdinate(origIdx, 2);
double ox2 = csOrig.getOrdinate(origIdx + 1, 0);
double oy2 = csOrig.getOrdinate(origIdx + 1, 1);
double oz2 = csOrig.getOrdinate(origIdx + 1, 2);
if(lx1 == ox1 && ly1 == oy1) {
lz1 = oz1;
} else {
double d1 = distance(ox1, oy1, lx1, ly1);
double d = distance(ox1, oy1, ox2, oy2);
lz1 = oz1 + (oz2 - oz1) * (d1 / d);
}
cs.setOrdinate(idx, 2, lz1);
}
示例2: writeCoordinate
import com.vividsolutions.jts.geom.CoordinateSequence; //导入方法依赖的package包/类
private void writeCoordinate(CoordinateSequence seq, int index, OutStream os)
throws IOException {
ByteOrderValues.putDouble(seq.getX(index), this.buf, this.byteOrder);
os.write(this.buf, 8);
ByteOrderValues.putDouble(seq.getY(index), this.buf, this.byteOrder);
os.write(this.buf, 8);
// only write 3rd dim if caller has requested it for this writer
if (this.outputDimension >= 3) {
// if 3rd dim is requested, only write it if the CoordinateSequence provides it
double ordVal = Coordinate.NULL_ORDINATE;
if (seq.getDimension() >= 3) {
ordVal = seq.getOrdinate(index, 2);
}
ByteOrderValues.putDouble(ordVal, this.buf, this.byteOrder);
os.write(this.buf, 8);
}
}
示例3: getAsPoints
import com.vividsolutions.jts.geom.CoordinateSequence; //导入方法依赖的package包/类
private static Points getAsPoints( CoordinateSequence seq, ICRS crs, boolean swapAxis ) {
int dim = seq.getDimension();
double[] coordinates = new double[ seq.size() * dim ];
int idx = 0;
for(int i = 0; i < seq.size(); i++) {
for(int j = 0; j < dim; j++) {
if(swapAxis) {
if(j == 0) {
coordinates[idx++] = seq.getOrdinate(i, 1);
} else if( j == 1) {
coordinates[idx++] = seq.getOrdinate(i, 0);
} else {
coordinates[idx++] = seq.getOrdinate(i, j);
}
} else {
coordinates[idx++] = seq.getOrdinate(i, j);
}
}
}
PackedCoordinateSequenceFactory factory = new PackedCoordinateSequenceFactory();
seq = factory.create(coordinates, dim);
return new JTSPoints( crs, seq );
}
示例4: averagePoint
import com.vividsolutions.jts.geom.CoordinateSequence; //导入方法依赖的package包/类
/**
* Computes a point which is the average of all coordinates
* in a sequence.
* If the sequence lies in a single plane,
* the computed point also lies in the plane.
*
* @param seq a coordinate sequence
* @return a Coordinate with averaged ordinates
*/
private Coordinate averagePoint(CoordinateSequence seq) {
Coordinate a = new Coordinate(0, 0, 0);
int n = seq.size();
for (int i = 0; i < n; i++) {
a.x += seq.getOrdinate(i, CoordinateSequence.X);
a.y += seq.getOrdinate(i, CoordinateSequence.Y);
a.z += seq.getOrdinate(i, CoordinateSequence.Z);
}
a.x /= n;
a.y /= n;
a.z /= n;
return a;
}
示例5: appendCoordinate
import com.vividsolutions.jts.geom.CoordinateSequence; //导入方法依赖的package包/类
/**
* Appends the i'th coordinate from the sequence to the writer
*
* @param seq the <code>CoordinateSequence</code> to process
* @param i the index of the coordinate to write
* @param writer the output writer to append to
*/
private void appendCoordinate(CoordinateSequence seq, int i, Writer writer)
throws IOException {
writer.write(this.writeNumber(seq.getX(i)) + " " + this.writeNumber(seq.getY(i)));
if (this.outputDimension >= 3 && seq.getDimension() >= 3) {
double z = seq.getOrdinate(i, 3);
if (!Double.isNaN(z)) {
writer.write(" ");
writer.write(this.writeNumber(z));
}
}
}
示例6: Orientation2D_Polygon
import com.vividsolutions.jts.geom.CoordinateSequence; //导入方法依赖的package包/类
public static double Orientation2D_Polygon(int n, CoordinateSequence V)
{
// first find rightmost lowest vertex of the polygon
int rmin = 0;
double xmin = V.getOrdinate(0, 0);
double ymin = V.getOrdinate(0, 1);
for (int i = 1; i < n; i++)
{
if (V.getOrdinate(i, 1) > ymin)
continue;
if (V.getOrdinate(i, 1) == ymin)
{ // just as low
if (V.getOrdinate(i, 0) < xmin) // and to left
continue;
}
rmin = i; // a new rightmost lowest vertex
xmin = V.getOrdinate(i, 0);
ymin = V.getOrdinate(i, 1);
}
// test orientation at this rmin vertex
// ccw <=> the edge leaving is left of the entering edge
if (rmin == n-1) {
rmin = 0;
}
if (rmin == 0)
return IsLeft(V.getCoordinate(n - 2), V.getCoordinate(0), V.getCoordinate(1));
else
return IsLeft(V.getCoordinate(rmin - 1), V.getCoordinate(rmin), V.getCoordinate((rmin + 1) % n));
}
示例7: isAllCoordsEqual
import com.vividsolutions.jts.geom.CoordinateSequence; //导入方法依赖的package包/类
boolean isAllCoordsEqual(CoordinateSequence seq, Coordinate coord)
{
for (int i = 0; i < seq.size(); i++) {
if (! coord.equals(seq.getCoordinate(i))) return false;
if (coord.x != seq.getOrdinate(i, CoordinateSequence.X)) return false;
if (coord.y != seq.getOrdinate(i, CoordinateSequence.Y)) return false;
if (coord.z != seq.getOrdinate(i, CoordinateSequence.Z)) return false;
}
return true;
}
示例8: 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;
}
示例9: writeCoordinate
import com.vividsolutions.jts.geom.CoordinateSequence; //导入方法依赖的package包/类
private void writeCoordinate(CoordinateSequence seq, int index, boolean output3D, OutStream os)
throws IOException {
ByteOrderValues.putDouble(seq.getX(index), buf, byteOrder);
os.write(buf, 8);
ByteOrderValues.putDouble(seq.getY(index), buf, byteOrder);
os.write(buf, 8);
if (output3D) {
// Set NaN values to 0
double zm = seq.getOrdinate(index, 2);
ByteOrderValues.putDouble(Double.isNaN(zm) ? 0d : zm, buf, byteOrder);
os.write(buf, 8);
}
}
示例10: averagePoint
import com.vividsolutions.jts.geom.CoordinateSequence; //导入方法依赖的package包/类
/**
* Computes a point which is the average of all coordinates
* in a sequence.
* If the sequence lies in a single plane,
* the computed point also lies in the plane.
*
* @param seq a coordinate sequence
* @return a Coordinate with averaged ordinates
*/
private Coordinate averagePoint(CoordinateSequence seq) {
Coordinate a = new Coordinate(0,0,0);
int n = seq.size();
for (int i = 0; i < n; i++) {
a.x += seq.getOrdinate(i, CoordinateSequence.X);
a.y += seq.getOrdinate(i, CoordinateSequence.Y);
a.z += seq.getOrdinate(i, CoordinateSequence.Z);
}
a.x /= n;
a.y /= n;
a.z /= n;
return a;
}
示例11: transform
import com.vividsolutions.jts.geom.CoordinateSequence; //导入方法依赖的package包/类
/**
* Applies this transformation to the i'th coordinate
* in the given CoordinateSequence.
*
* @param seq a <code>CoordinateSequence</code>
* @param i the index of the coordinate to transform
*/
public void transform(CoordinateSequence seq, int i) {
double xp = this.m00 * seq.getOrdinate(i, 0) + this.m01 * seq.getOrdinate(i, 1) + this.m02;
double yp = this.m10 * seq.getOrdinate(i, 0) + this.m11 * seq.getOrdinate(i, 1) + this.m12;
seq.setOrdinate(i, 0, xp);
seq.setOrdinate(i, 1, yp);
}
示例12: transform
import com.vividsolutions.jts.geom.CoordinateSequence; //导入方法依赖的package包/类
/**
* Applies this transformation to the i'th coordinate
* in the given CoordinateSequence.
*
* @param seq a <code>CoordinateSequence</code>
* @param i the index of the coordinate to transform
*/
public void transform(CoordinateSequence seq, int i) {
double xp = m00 * seq.getOrdinate(i, 0) + m01 * seq.getOrdinate(i, 1) + m02;
double yp = m10 * seq.getOrdinate(i, 0) + m11 * seq.getOrdinate(i, 1) + m12;
seq.setOrdinate(i, 0, xp);
seq.setOrdinate(i, 1, yp);
}