@Test public void placemarkReadTest() throws IOException, XMLStreamException, KmlException, URISyntaxException { final KmlReader reader = new KmlReader(); reader.setInput(new File(pathToTestFile)); final Kml kmlObjects = reader.read(); reader.dispose(); final Feature placemark = kmlObjects.getAbstractFeature(); assertTrue(placemark.getType().equals(KmlModelConstants.TYPE_PLACEMARK)); assertEquals( "Google Earth - New Placemark", placemark.getProperty(KmlModelConstants.ATT_NAME.getName()).getValue()); assertEquals( "Some Descriptive text.", placemark.getProperty(KmlModelConstants.ATT_DESCRIPTION.getName()).getValue()); final AbstractView view = (AbstractView) placemark.getProperty(KmlModelConstants.ATT_VIEW.getName()).getValue(); assertTrue(view instanceof LookAt); LookAt lookAt = (LookAt) view; assertEquals(-90.86879847669974, lookAt.getLongitude(), DELTA); assertEquals(48.25330383601299, lookAt.getLatitude(), DELTA); assertEquals(2.7, lookAt.getHeading(), DELTA); assertEquals(8.3, lookAt.getTilt(), DELTA); assertEquals(440.8, lookAt.getRange(), DELTA); final AbstractGeometry geometry = (AbstractGeometry) placemark.getProperty(KmlModelConstants.ATT_PLACEMARK_GEOMETRY.getName()).getValue(); assertTrue(geometry instanceof Point); Point point = (Point) geometry; final CoordinateSequence coordinates = point.getCoordinateSequence(); assertEquals(1, coordinates.size()); Coordinate coordinate = coordinates.getCoordinate(0); assertEquals(-90.86948943473118, coordinate.x, DELTA); assertEquals(48.25450093195546, coordinate.y, DELTA); assertEquals(0, coordinate.z, DELTA); }
private List<Feature> buildFCResultPixelCorner() throws NoSuchAuthorityCodeException, FactoryException { FeatureType type = buildFeatureType(); final List<Feature> featureList = new ArrayList<Feature>(); GeometryFactory geometryFactory = new GeometryFactory(); double buffX = 0; double buffY = 0; for (int y = 0; y < max; y++) { for (int x = 0; x < max; x++) { buffX = x; buffY = y + 1.0; Point pos = geometryFactory.createPoint(new Coordinate(buffX, buffY)); LinearRing line = geometryFactory.createLinearRing( new Coordinate[] { new Coordinate(buffX, buffY), new Coordinate(buffX + 1.0, buffY), new Coordinate(buffX + 1.0, buffY - 1.0), new Coordinate(buffX, buffY - 1.0), new Coordinate(buffX, buffY) }); Feature myfeature = FeatureUtilities.defaultFeature(type, "id-" + x + "-" + y); myfeature.getProperty("cellgeom").setValue(geometryFactory.createPolygon(line, null)); myfeature.getProperty("position").setValue(pos); myfeature.getProperty("orientation").setValue(PixelInCell.CELL_CENTER.name()); myfeature.getProperty("band-0").setValue(0.0); myfeature.getProperty("band-1").setValue((Integer) x); myfeature.getProperty("band-2").setValue((Integer) y); featureList.add((x + (y * max)), myfeature); } } return featureList; }