Exemple #1
0
 private CoordinateSequence decimate(LiteCoordinateSequence seq) {
   double[] coords = seq.getArray();
   int numDoubles = coords.length;
   int dim = seq.getDimension();
   int readDoubles = 0;
   double prevx, currx, prevy, curry, diffx, diffy;
   for (int currentDoubles = 0; currentDoubles < numDoubles; currentDoubles += dim) {
     if (currentDoubles >= dim && currentDoubles < numDoubles - 1) {
       prevx = coords[readDoubles - dim];
       currx = coords[currentDoubles];
       diffx = Math.abs(prevx - currx);
       prevy = coords[readDoubles - dim + 1];
       curry = coords[currentDoubles + 1];
       diffy = Math.abs(prevy - curry);
       if (diffx > spanx || diffy > spany) {
         readDoubles = copyCoordinate(coords, dim, readDoubles, currentDoubles);
       }
     } else {
       readDoubles = copyCoordinate(coords, dim, readDoubles, currentDoubles);
     }
   }
   double[] newCoords = new double[readDoubles];
   System.arraycopy(coords, 0, newCoords, 0, readDoubles);
   seq.setArray(newCoords);
   return seq;
 }
Exemple #2
0
 /**
  * @param geom
  * @param seq
  */
 private boolean decimateOnEnvelope(Geometry geom, LiteCoordinateSequence seq) {
   Envelope env = geom.getEnvelopeInternal();
   if (env.getWidth() <= spanx && env.getHeight() <= spany) {
     double[] coords = seq.getArray();
     int dim = seq.getDimension();
     double[] newcoords = new double[dim * 2];
     for (int i = 0; i < dim; i++) {
       newcoords[i] = coords[i];
       newcoords[dim + i] = coords[coords.length - dim + i];
     }
     seq.setArray(coords);
     return true;
   }
   return false;
 }