예제 #1
0
  /**
   * @throws XMLStreamException
   * @throws FactoryConfigurationError
   * @throws IOException
   * @throws UnknownCRSException
   * @throws TransformationException
   */
  @Test
  public void testPoint2()
      throws XMLStreamException, FactoryConfigurationError, IOException, TransformationException,
          UnknownCRSException {
    XMLStreamReaderWrapper xmlReader =
        new XMLStreamReaderWrapper(this.getClass().getResource(BASE_DIR + POINT2_FILE));
    xmlReader.nextTag();
    Point point = new GML2GeometryReader().parsePoint(xmlReader, null);
    Assert.assertEquals(5.0, point.get0(), DELTA);
    Assert.assertEquals(30.0, point.get1(), DELTA);

    XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
    outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", new Boolean(true));
    XMLMemoryStreamWriter memoryWriter = new XMLMemoryStreamWriter();

    SchemaLocationXMLStreamWriter writer =
        new SchemaLocationXMLStreamWriter(
            memoryWriter.getXMLStreamWriter(), SCHEMA_LOCATION_ATTRIBUTE);
    GML2GeometryWriter exporter = new GML2GeometryWriter(writer, null, null, new HashSet<String>());

    writer.setPrefix("gml", "http://www.opengis.net/gml");

    exporter.export(point);
    writer.flush();

    XMLAssert.assertValidity(memoryWriter.getReader(), SCHEMA_LOCATION);
  }
예제 #2
0
 @Override
 public void getCoordinate(int index, Coordinate coord) {
   Point point = get(index);
   coord.x = point.get0();
   coord.y = point.get1();
   coord.z = point.get2();
 }
예제 #3
0
 @Override
 public Envelope expandEnvelope(Envelope env) {
   for (Point p : this) {
     env.expandToInclude(p.get0(), p.get1());
   }
   return env;
 }
예제 #4
0
 @Override
 public Coordinate[] toCoordinateArray() {
   Coordinate[] coords = new Coordinate[size()];
   int i = 0;
   for (Point p : this) {
     coords[i++] = new Coordinate(p.get0(), p.get1());
   }
   return coords;
 }
예제 #5
0
  /**
   * @throws XMLStreamException
   * @throws FactoryConfigurationError
   * @throws IOException
   * @throws UnknownCRSException
   * @throws TransformationException
   */
  @Test
  public void testPoint()
      throws XMLStreamException, FactoryConfigurationError, IOException, UnknownCRSException,
          TransformationException {
    XMLStreamReaderWrapper xmlReader =
        new XMLStreamReaderWrapper(this.getClass().getResource(BASE_DIR + POINT_FILE));
    xmlReader.nextTag();

    Assert.assertEquals(XMLStreamConstants.START_ELEMENT, xmlReader.getEventType());
    Assert.assertEquals(new QName(GML21NS, "Point"), xmlReader.getName());

    Point point = new GML2GeometryReader().parsePoint(xmlReader, null);
    Assert.assertEquals(XMLStreamConstants.END_ELEMENT, xmlReader.getEventType());
    Assert.assertEquals(new QName(GML21NS, "Point"), xmlReader.getName());
    Assert.assertEquals(5.0, point.get0(), DELTA);
    Assert.assertEquals(40.0, point.get1(), DELTA);
    Assert.assertEquals(
        CRSRegistry.lookup("http://www.opengis.net/gml/srs/epsg.xml#4326"),
        point.getCoordinateSystem().getWrappedCRS());

    XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
    outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", new Boolean(true));
    XMLMemoryStreamWriter memoryWriter = new XMLMemoryStreamWriter();

    SchemaLocationXMLStreamWriter writer =
        new SchemaLocationXMLStreamWriter(
            memoryWriter.getXMLStreamWriter(), SCHEMA_LOCATION_ATTRIBUTE);
    GML2GeometryWriter exporter = new GML2GeometryWriter(writer, null, null, new HashSet<String>());

    writer.setPrefix("gml", "http://www.opengis.net/gml");

    exporter.export(point);
    writer.flush();

    XMLAssert.assertValidity(memoryWriter.getReader(), SCHEMA_LOCATION);
  }
예제 #6
0
 private void comparePoint(double x, double y, Point point) {
   Assert.assertEquals(x, point.get0(), DELTA);
   Assert.assertEquals(y, point.get1(), DELTA);
 }
예제 #7
0
 @Override
 public Coordinate getCoordinateCopy(int index) {
   Point point = get(index);
   return new Coordinate(point.get0(), point.get1(), point.get2());
 }