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;
}
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;
}
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();
}
Aggregations