Esempio n. 1
0
  public static Geometry loadFromTextFileDbg(String textFileName) throws FileNotFoundException {
    String fullPath = textFileName;
    // string fullCSVPathName = System.IO.Path.Combine( directoryPath ,
    // CsvFileName);
    File fileInfo = new File(fullPath);

    Scanner scanner = new Scanner(fileInfo);

    Geometry geom = null;

    // grab first line
    String line = scanner.nextLine();
    String geomTypeString = line.substring(1);
    if (geomTypeString.equalsIgnoreCase("polygon")) geom = new Polygon();
    else if (geomTypeString.equalsIgnoreCase("polyline")) geom = new Polyline();
    else if (geomTypeString.equalsIgnoreCase("multipoint")) geom = new MultiPoint();
    else if (geomTypeString.equalsIgnoreCase("point")) geom = new Point();

    while (line.startsWith("*")) if (scanner.hasNextLine()) line = scanner.nextLine();

    int j = 0;
    Geometry.Type geomType = geom.getType();
    while (scanner.hasNextLine()) {
      String[] parsedLine = line.split("\\s+");
      double xVal = Double.parseDouble(parsedLine[0]);
      double yVal = Double.parseDouble(parsedLine[1]);
      if (j == 0 && (geomType == Geometry.Type.Polygon || geomType == Geometry.Type.Polyline))
        ((MultiPath) geom).startPath(xVal, yVal);
      else {
        if (geomType == Geometry.Type.Polygon || geomType == Geometry.Type.Polyline)
          ((MultiPath) geom).lineTo(xVal, yVal);
        else if (geomType == Geometry.Type.MultiPoint) ((MultiPoint) geom).add(xVal, yVal);
        // else if(geomType == Geometry.Type.Point)
        // Point geom = null;//new Point(xVal, yVal);
      }
      j++;
      line = scanner.nextLine();
    }

    scanner.close();

    return geom;
  }
 /**
  * Inserts vertices from the given multipath into this multipath. All added vertices are connected
  * by linear segments with each other and with the existing vertices.
  *
  * @param pathIndex The path index in this multipath to insert points to. Must correspond to an
  *     existing path.
  * @param beforePointIndex The point index before all other vertices to insert in the given path
  *     of this multipath. This value must be between 0 and GetPathSize(pathIndex), or -1 to insert
  *     points at the end of the given path.
  * @param src The source multipath.
  * @param srcPathIndex The source path index to copy points from.
  * @param srcPointIndexFrom The start point in the source path to start copying from.
  * @param srcPointCount The count of points to add.
  * @param bForward When FALSE, the points are inserted in reverse order.
  */
 public void insertPoints(
     int pathIndex,
     int beforePointIndex,
     MultiPath src,
     int srcPathIndex,
     int srcPointIndexFrom,
     int srcPointCount,
     boolean bForward) {
   m_impl.insertPoints(
       pathIndex,
       beforePointIndex,
       (MultiPathImpl) src._getImpl(),
       srcPathIndex,
       srcPointIndexFrom,
       srcPointCount,
       bForward);
 }
 /**
  * Copies a path from another multipath.
  *
  * @param src The multipath to copy from.
  * @param srcPathIndex The index of the path in the the source MultiPath.
  * @param bForward When FALSE, the points are inserted in reverse order.
  */
 public void addPath(MultiPath src, int srcPathIndex, boolean bForward) {
   m_impl.addPath((MultiPathImpl) src._getImpl(), srcPathIndex, bForward);
 }
 /**
  * Inserts a path from another multipath.
  *
  * @param pathIndex The start index of the multipath to insert.
  * @param src The multipath to insert into this multipath. Can be the same as the multipath being
  *     modified.
  * @param srcPathIndex The start index to insert the path into the multipath.
  * @param bForward When FALSE, the points are inserted in reverse order.
  */
 public void insertPath(int pathIndex, MultiPath src, int srcPathIndex, boolean bForward) {
   m_impl.insertPath(pathIndex, (MultiPathImpl) src._getImpl(), srcPathIndex, bForward);
 }
 /**
  * Appends all paths from another multipath.
  *
  * @param src The multipath to append to this multipath.
  * @param bReversePaths TRUE if the multipath is added should be added with its paths reversed.
  */
 public void add(MultiPath src, boolean bReversePaths) {
   m_impl.add((MultiPathImpl) src._getImpl(), bReversePaths);
 }