예제 #1
0
  public void testPolygonNoHoles() throws IOException, URISyntaxException {
    final URL resource = getClass().getClassLoader().getResource("Polygon.shp");
    final File file = new File(resource.toURI());
    final FileInputStream is = new FileInputStream(file);

    SHPFile shp = null;
    try {
      shp = new SHPFile();
      shp.open(is);

      final SHPRecord record = shp.getRecord(1148, 212);
      assertEquals(5, record.getShapeType());

      final Polygon polygon = (Polygon) record.getGeometry();
      final List<List<Point>> parts = polygon.getParts();
      assertEquals(2, parts.size());

      final List<Point> points = parts.get(0);
      assertEquals(5, points.size());

      final Point point = points.get(1);
      assertEquals(444569, (int) point.getX());
    } finally {
      shp.close();
      FileUtils.closeInputStream(is);
    }
  }
예제 #2
0
  public void testReadHeader() throws IOException, URISyntaxException {
    final URL resource = getClass().getClassLoader().getResource("Polygon.shp");
    final File file = new File(resource.toURI());
    final FileInputStream is = new FileInputStream(file);

    SHPFile shp = null;
    try {
      shp = new SHPFile();
      shp.open(is);

      final SHPHeader header = shp.getHeader();

      assertNotNull(header);
    } finally {
      shp.close();
      FileUtils.closeInputStream(is);
    }
  }
예제 #3
0
  public void testPoint() throws IOException, URISyntaxException {
    final URL resource = getClass().getClassLoader().getResource("Point.shp");
    final File file = new File(resource.toURI());
    final FileInputStream is = new FileInputStream(file);

    SHPFile shp = null;
    try {
      shp = new SHPFile();
      shp.open(is);

      final SHPRecord record = shp.getRecord(156, 20);
      assertEquals(1, record.getShapeType());

      final Point point = (Point) record.getGeometry();
      assertEquals(447199, (int) point.getX());
    } finally {
      shp.close();
      FileUtils.closeInputStream(is);
    }
  }
예제 #4
0
  public void testMultiPointSingle() throws IOException, URISyntaxException {
    final URL resource = getClass().getClassLoader().getResource("MultiPoint.shp");
    final File file = new File(resource.toURI());
    final FileInputStream is = new FileInputStream(file);

    SHPFile shp = null;
    try {
      shp = new SHPFile();
      shp.open(is);

      final SHPRecord record = shp.getRecord(196, 56);
      assertEquals(8, record.getShapeType());

      final MultiPoint multipoint = (MultiPoint) record.getGeometry();
      assertEquals(1, multipoint.getPoints().size());

      final Point point = multipoint.getPoints().get(0);
      assertEquals(444301, (int) point.getX());
    } finally {
      shp.close();
      FileUtils.closeInputStream(is);
    }
  }