if (!duplicateSources.isEmpty() && (null == doc.getUpdateId())) { // (can't duplicate updating document)
doc.setDuplicateFrom(duplicateSources.getFirst());
}
//GeoRSS
GeoRSSModule geoRSSModule = GeoRSSUtils.getGeoRSS(entry); //currently does not handle <georss:circle>
if (null != geoRSSModule)
{
if (null != geoRSSModule.getPosition())
{
double lat = geoRSSModule.getPosition().getLatitude();
double lon = geoRSSModule.getPosition().getLongitude();
GeoPojo gp = new GeoPojo();
gp.lat = lat;
gp.lon = lon;
doc.setDocGeo(gp);
}
if (null != geoRSSModule.getGeometry())
{
AbstractGeometry ag = geoRSSModule.getGeometry();
if(ag.getClass().equals(new LineString().getClass()))
{ //<georss:line>
LineString ls = ((LineString)geoRSSModule.getGeometry());
double latAvg = 0.0;
double lonAvg = 0.0;
int length = ls.getPositionList().size();
for (int i = 0; i < length; i ++)
{
latAvg += ls.getPositionList().getLatitude(i);
lonAvg += ls.getPositionList().getLongitude(i);
}
latAvg = latAvg/length;
lonAvg = lonAvg/length;
GeoPojo gp = new GeoPojo();
gp.lat = latAvg;
gp.lon = lonAvg;
doc.setDocGeo(gp);
}
else if (ag.getClass().equals(new Polygon().getClass())) //<georss:polygon>
{
Polygon poly = ((Polygon)geoRSSModule.getGeometry());
AbstractRing ar = poly.getExterior();
LinearRing lr = (LinearRing)ar;
double latAvg = 0.0;
double lonAvg = 0.0;
int length = lr.getPositionList().size();
for (int i = 0; i < length; i ++)
{
latAvg += lr.getPositionList().getLatitude(i);
lonAvg += lr.getPositionList().getLongitude(i);
}
latAvg = latAvg/length;
lonAvg = lonAvg/length;
GeoPojo gp = new GeoPojo();
gp.lat = latAvg;
gp.lon = lonAvg;
doc.setDocGeo(gp);
}
else if(ag.getClass().equals(new Envelope().getClass()))
{ //<georss:box>
Envelope env = ((Envelope)geoRSSModule.getGeometry());
double latAvg = (env.getMaxLatitude()+env.getMinLatitude())/2;
double lonAvg = (env.getMaxLongitude()+env.getMinLongitude())/2;
GeoPojo gp = new GeoPojo();