Merge "Issue #1605 Improved finding closest area locations. " into development
Former-commit-id:b047a0393f
[formerly 1c778e9c7140214bed727a2eac73c0461d134341] Former-commit-id:60f3f46d19
This commit is contained in:
commit
4952a3f595
2 changed files with 32 additions and 6 deletions
|
@ -29,14 +29,21 @@ import com.vividsolutions.jts.geom.prep.PreparedGeometry;
|
|||
import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description ------------ ---------- -----------
|
||||
* --------------------------
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 25, 2012 #15425 Qinglu Lin Updated createClosestPoint().
|
||||
* Feb 13, 2012 1605 jsanchez Calculated the point based on lat,lon values.
|
||||
*
|
||||
* @author jsanchez Sep 25, 2012 #15425 Qinglu Lin Updated createClosestPoint().
|
||||
* </pre>
|
||||
*
|
||||
* @author jsanchez
|
||||
* @version 1.0
|
||||
*/
|
||||
public class DbAreaSourceDataAdaptor extends AbstractDbSourceDataAdaptor {
|
||||
|
||||
|
@ -46,6 +53,10 @@ public class DbAreaSourceDataAdaptor extends AbstractDbSourceDataAdaptor {
|
|||
|
||||
private static final String cwaField = "cwa";
|
||||
|
||||
private static final String longitude = "lon";
|
||||
|
||||
private static final String latitude = "lat";
|
||||
|
||||
public DbAreaSourceDataAdaptor(PathcastConfiguration pathcastConfiguration,
|
||||
UnitConverter distanceToMeters, Geometry searchArea,
|
||||
String localizedSite) throws VizException {
|
||||
|
@ -69,6 +80,8 @@ public class DbAreaSourceDataAdaptor extends AbstractDbSourceDataAdaptor {
|
|||
ptFields.add(pointField);
|
||||
ptFields.add(useDirectionField);
|
||||
ptFields.add(suppressedDirectionsField);
|
||||
ptFields.add(longitude);
|
||||
ptFields.add(latitude);
|
||||
|
||||
List<String> fields = null;
|
||||
if (sortBy != null && sortBy.length > 0) {
|
||||
|
@ -96,7 +109,7 @@ public class DbAreaSourceDataAdaptor extends AbstractDbSourceDataAdaptor {
|
|||
Map<String, Object> attributes = ptRslt.attributes;
|
||||
|
||||
String name = String.valueOf(attributes.get(pointField));
|
||||
Coordinate point = ptRslt.geometry.getCoordinate();
|
||||
Coordinate point = getPoint(attributes);
|
||||
int population = getPopulation(ptFields, attributes);
|
||||
int warngenlev = getWangenlev(ptFields, attributes);
|
||||
List<String> partOfArea = getPartOfArea(ptFields, attributes,
|
||||
|
@ -264,4 +277,17 @@ public class DbAreaSourceDataAdaptor extends AbstractDbSourceDataAdaptor {
|
|||
|
||||
return directions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Coordinate based on the lat,lon values in the attributes.
|
||||
*
|
||||
* @param attributes
|
||||
* @return
|
||||
*/
|
||||
private Coordinate getPoint(Map<String, Object> attributes) {
|
||||
double lat = Double.valueOf(String.valueOf(attributes.get(latitude)));
|
||||
double lon = Double.valueOf(String.valueOf(attributes.get(longitude)));
|
||||
|
||||
return new Coordinate(lon, lat);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.apache.commons.lang.ArrayUtils;
|
|||
* Mar 3, 2011 jsanchez Initial creation
|
||||
* Sep 25, 2012 15425 Qinglu Lin Implemented sorting on 'gid' in ascending order.
|
||||
* Oct 17, 2012 jsanchez Refactored the enum sort to be more flexible.
|
||||
* Feb 14, 2013 1605 jsanchez Updated the distance comparison for more accuracy.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -148,8 +149,7 @@ public class ClosestPointComparator implements Comparator<ClosestPoint> {
|
|||
value = cp1.parentArea.compareTo(cp2.parentArea);
|
||||
break;
|
||||
case DISTANCE:
|
||||
value = new Integer(cp1.roundedDistance)
|
||||
.compareTo(cp2.roundedDistance);
|
||||
value = new Double(cp1.distance).compareTo(cp2.distance);
|
||||
break;
|
||||
case GID:
|
||||
value = new Integer(cp1.gid).compareTo(cp2.gid);
|
||||
|
|
Loading…
Add table
Reference in a new issue