Search in sources :

Example 1 with WktDecoder

use of org.geolatte.geom.codec.WktDecoder in project hibernate-orm by hibernate.

the class GeomEntity method createFrom.

public static GeomEntity createFrom(TestDataElement element) throws WktDecodeException {
    WktDecoder decoder = Wkt.newDecoder(Wkt.Dialect.POSTGIS_EWKT_1);
    Geometry geom = decoder.decode(element.wkt);
    GeomEntity result = new GeomEntity();
    result.setId(element.id);
    result.setGeom(geom);
    result.setType(element.type);
    return result;
}
Also used : Geometry(org.geolatte.geom.Geometry) WktDecoder(org.geolatte.geom.codec.WktDecoder)

Example 2 with WktDecoder

use of org.geolatte.geom.codec.WktDecoder in project hibernate-orm by hibernate.

the class GeomEntity method createFrom.

public static GeomEntity createFrom(TestDataElement element) throws ParseException {
    WktDecoder decoder = Wkt.newDecoder(Wkt.Dialect.POSTGIS_EWKT_1);
    Geometry geom = JTS.to(decoder.decode(element.wkt));
    GeomEntity result = new GeomEntity();
    result.setId(element.id);
    result.setGeom(geom);
    result.setType(element.type);
    return result;
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) WktDecoder(org.geolatte.geom.codec.WktDecoder)

Example 3 with WktDecoder

use of org.geolatte.geom.codec.WktDecoder in project hibernate-orm by hibernate.

the class DataSourceUtils method expectedGeoms.

/**
	 * Returns the JTS geometries that are expected of a decoding of the testsuite-suite object's geometry.
	 * <p/>
	 * <p>This method reads the WKT of the testsuite-suite objects and returns the result.</p>
	 *
	 * @param type type of geometry
	 *
	 * @return map of identifier and JTS geometry
	 */
public Map<Integer, Geometry> expectedGeoms(String type, TestData testData) {
    Map<Integer, Geometry> result = new HashMap<Integer, Geometry>();
    WktDecoder decoder = Wkt.newDecoder();
    for (TestDataElement testDataElement : testData) {
        if (testDataElement.type.equalsIgnoreCase(type)) {
            try {
                result.put(testDataElement.id, decoder.decode(testDataElement.wkt));
            } catch (WktDecodeException e) {
                System.out.println(String.format("Parsing WKT fails for case %d : %s", testDataElement.id, testDataElement.wkt));
                throw new RuntimeException(e);
            }
        }
    }
    return result;
}
Also used : Geometry(org.geolatte.geom.Geometry) WktDecoder(org.geolatte.geom.codec.WktDecoder) HashMap(java.util.HashMap) WktDecodeException(org.geolatte.geom.codec.WktDecodeException)

Aggregations

WktDecoder (org.geolatte.geom.codec.WktDecoder)3 Geometry (org.geolatte.geom.Geometry)2 Geometry (com.vividsolutions.jts.geom.Geometry)1 HashMap (java.util.HashMap)1 WktDecodeException (org.geolatte.geom.codec.WktDecodeException)1