Search in sources :

Example 1 with Position

use of org.apache.abdera.ext.geo.Position in project ddf by codice.

the class AtomTransformer method getGeoRssPositions.

private List<Position> getGeoRssPositions(Metacard metacard) {
    List<Position> georssPositions = new ArrayList<Position>();
    for (AttributeDescriptor ad : metacard.getMetacardType().getAttributeDescriptors()) {
        if (ad != null && ad.getType() != null && BasicTypes.GEO_TYPE.getAttributeFormat().equals(ad.getType().getAttributeFormat())) {
            Attribute geoAttribute = metacard.getAttribute(ad.getName());
            if (geoAttribute == null) {
                continue;
            }
            for (Serializable geo : geoAttribute.getValues()) {
                if (geo != null) {
                    try {
                        Geometry geometry = new WKTReader(GEOMETRY_FACTORY).read(geo.toString());
                        CompositeGeometry formatter = CompositeGeometry.getCompositeGeometry(geometry);
                        if (null != formatter) {
                            georssPositions.addAll(formatter.toGeoRssPositions());
                        } else {
                            LOGGER.debug("When cycling through geometries, could not get composite geometry [{}]", geo);
                        }
                    } catch (ParseException e) {
                        LOGGER.info("When cycling through geometries, could not parse [{}]", geo, e);
                    }
                }
            }
        }
    }
    return georssPositions;
}
Also used : CompositeGeometry(ddf.geo.formatter.CompositeGeometry) Geometry(org.locationtech.jts.geom.Geometry) Serializable(java.io.Serializable) Position(org.apache.abdera.ext.geo.Position) Attribute(ddf.catalog.data.Attribute) CompositeGeometry(ddf.geo.formatter.CompositeGeometry) ArrayList(java.util.ArrayList) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MimeTypeParseException(javax.activation.MimeTypeParseException) ParseException(org.locationtech.jts.io.ParseException) WKTReader(org.locationtech.jts.io.WKTReader)

Example 2 with Position

use of org.apache.abdera.ext.geo.Position in project ddf by codice.

the class MultiPoint method toGeoRssPositions.

@Override
public List<Position> toGeoRssPositions() {
    List<Position> list = new ArrayList<Position>();
    for (int i = 0; i < geometry.getCoordinates().length; i++) {
        Coordinate jtsCoordinate = geometry.getCoordinates()[i];
        list.add(new org.apache.abdera.ext.geo.Point(convert(jtsCoordinate)));
    }
    return list;
}
Also used : Position(org.apache.abdera.ext.geo.Position) Coordinate(org.locationtech.jts.geom.Coordinate) ArrayList(java.util.ArrayList)

Example 3 with Position

use of org.apache.abdera.ext.geo.Position in project ddf by codice.

the class AbstractTestCompositeGeometry method getSampleAtomEntry.

/**
 * Creates an Atom Entry with GeoRSS encoded in GML.
 *
 * @param composite
 * @return Atom entry as text
 * @throws org.locationtech.jts.io.ParseException
 * @throws IOException
 */
protected String getSampleAtomEntry(CompositeGeometry composite) throws IOException {
    List<Position> positions = composite.toGeoRssPositions();
    Entry sampleEntry = ABDERA.newEntry();
    for (Position pos : positions) {
        GeoHelper.addPosition(sampleEntry, pos, Encoding.GML);
    }
    StringWriter writer = new StringWriter();
    sampleEntry.writeTo(writer);
    return writer.toString();
}
Also used : Entry(org.apache.abdera.model.Entry) StringWriter(java.io.StringWriter) Position(org.apache.abdera.ext.geo.Position)

Aggregations

Position (org.apache.abdera.ext.geo.Position)3 ArrayList (java.util.ArrayList)2 Attribute (ddf.catalog.data.Attribute)1 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)1 CompositeGeometry (ddf.geo.formatter.CompositeGeometry)1 Serializable (java.io.Serializable)1 StringWriter (java.io.StringWriter)1 MimeTypeParseException (javax.activation.MimeTypeParseException)1 Entry (org.apache.abdera.model.Entry)1 Coordinate (org.locationtech.jts.geom.Coordinate)1 Geometry (org.locationtech.jts.geom.Geometry)1 ParseException (org.locationtech.jts.io.ParseException)1 WKTReader (org.locationtech.jts.io.WKTReader)1