示例#1
0
  @Override
  public void copyTo(Geometry dst) {
    if (dst.getType() != Type.Point) throw new IllegalArgumentException();

    Point pointDst = (Point) dst;
    dst._touch();

    if (m_attributes == null) {
      pointDst.setEmpty();
      pointDst.m_attributes = null;
      pointDst.assignVertexDescription(m_description);
    } else {
      pointDst.assignVertexDescription(m_description);
      pointDst.resizeAttributes(m_description._getTotalComponents());
      attributeCopy(m_attributes, pointDst.m_attributes, m_description._getTotalComponents());
    }
  }
  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;
  }
  @Override
  public void copyTo(Geometry dst) {
    if (getType() != dst.getType()) throw new IllegalArgumentException();

    m_impl.copyTo((Geometry) dst._getImpl());
  }