@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; }
private static double[] getLengthsFromElevation(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; } return new double[] { trueLength, flatLength }; }
public double distanceAlong() { CoordinateSequence cs = ( (LineString)(edge.getGeometry()) ).getCoordinateSequence(); double dist = 0; double x0 = cs.getX(0); double y0 = cs.getY(0); for (int s = 1; s < seg; s++) { double x1 = cs.getX(s); double y1 = cs.getY(s); dist += SphericalDistanceLibrary.fastDistance(y0, x0, y1, x1); x0 = x1; y0 = y1; } dist += SphericalDistanceLibrary.fastDistance(y0, x0, y, x); // dist along partial segment return dist; }
public double distanceToEnd() { CoordinateSequence cs = ( (LineString)(edge.getGeometry()) ).getCoordinateSequence(); int s = seg + 1; double x0 = cs.getX(s); double y0 = cs.getY(s); double dist = SphericalDistanceLibrary.fastDistance(y0, x0, y, x); // dist along partial segment int nc = cs.size(); for (; s < nc; s++) { double x1 = cs.getX(s); double y1 = cs.getY(s); dist += SphericalDistanceLibrary.fastDistance(y0, x0, y1, x1); x0 = x1; y0 = y1; } return dist; } }
/** * Generates the WKT for a <tt>LINESTRING</tt> * specified by a {@link CoordinateSequence}. * * @param seq the sequence to write * * @return the WKT string */ public static String toLineString(CoordinateSequence seq) { StringBuffer buf = new StringBuffer(); buf.append("LINESTRING "); if (seq.size() == 0) buf.append(" EMPTY"); else { buf.append("("); for (int i = 0; i < seq.size(); i++) { if (i > 0) buf.append(", "); buf.append(seq.getX(i) + " " + seq.getY(i)); } buf.append(")"); } return buf.toString(); }
public Envelope getEnvelope() { Envelope env = new Envelope(); for (int i = start; i < end; i++) { env.expandToInclude(pts.getX(i), pts.getY(i)); } return env; }
public OctagonalEnvelope expandToInclude(CoordinateSequence seq) { for (int i = 0; i < seq.size(); i++) { double x = seq.getX(i); double y = seq.getY(i); expandToInclude(x, y); } return this; }
/** * 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(writeNumber(seq.getX(i)) + " " + writeNumber(seq.getY(i))); if (outputDimension >= 3 && seq.getDimension() >= 3) { double z = seq.getOrdinate(i, 3); if (! Double.isNaN(z)) { writer.write(" "); writer.write(writeNumber(z)); } } }
protected Envelope computeEnvelopeInternal() { if (isEmpty()) { return new Envelope(); } Envelope env = new Envelope(); env.expandToInclude(coordinates.getX(0), coordinates.getY(0)); return env; }
private void writeCoordinate(CoordinateSequence seq, int index, 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); // only write 3rd dim if caller has requested it for this writer if (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, buf, byteOrder); os.write(buf, 8); } } }
public OctagonalEnvelope expandToInclude(CoordinateSequence seq) { for (int i = 0; i < seq.size(); i++) { double x = seq.getX(i); double y = seq.getY(i); expandToInclude(x, y); } return this; }
public void addCoordinateSequence(final CoordinateSequence _seq, final Object[] _datas, final CtuluCommandContainer _cmd) { if (_seq == null || _seq.size() != 1) { return; } add(_seq.getX(0), _seq.getY(0), _seq.getOrdinate(0, 2), _datas == null ? null : Arrays.asList(_datas), _cmd); }
public final boolean point(final GrPoint _pt, final int _ligneIdx, final int _pointIdx) { // On s'appuie sur la mthode GISMultiPoint.getCoordinateSequence() cre pour l'occasion et non GISMultiPoint.getCoordinates() // pour rcuperer les coordonnes d'un point. En effet, recuprer le tableau des coordonnes s'avre terriblement // penalisant pour l'affichage. final CoordinateSequence g = ((GISMultiPoint) geometries_.getGeometry(_ligneIdx)).getCoordinateSequence(); _pt.x_ = g.getX(_pointIdx); _pt.y_ = g.getY(_pointIdx); return true; }
public void setCoordinateSequence(final int _idx, final CoordinateSequence _newSeq, final CtuluCommandContainer _cmd) { if (_newSeq != null && _newSeq.size() == 1) { set(_idx, _newSeq.getX(0), _newSeq.getY(0), _cmd); } }
public double getPtX(final int _i) { if (onlyPoints_) { return ((Point)geometries_.getGeometry(_i)).getX(); } else { CoordinateSequence seq= ((GISCoordinateSequenceContainerInterface)geometries_.getGeometry(idx2geom_[_i][0])).getCoordinateSequence(); return seq.getX(idx2geom_[_i][1]); } // return geometries_.getX(_i); }
public boolean fillListWithPoint(final GISCollectionPointInteface _listToFill){ final CoordinateSequence seq = getCoordinateSequence(); final int nb = seq.size(); for (int i = 0; i < nb; i++) { _listToFill.add(seq.getX(i), seq.getY(i), seq.getOrdinate(i, 2)); } return true; }
public MultiPoint createMultiPoint(final CoordinateSequence _coordinates) { if (_coordinates == null) { return null; } final int n = _coordinates.size(); final GISPoint[] pt = new GISPoint[n]; for (int i = 0; i < n; i++) { pt[i] = (GISPoint) createPoint(_coordinates.getX(i), _coordinates.getY(i), _coordinates.getOrdinate(i, CoordinateSequence.Z)); } return new GISMultiPoint(pt); }