Skip to content

Commit

Permalink
Update flagged point (#39)
Browse files Browse the repository at this point in the history
* Updating flagged point

* Updating cloudera path

* clean up and logging unknown location items
  • Loading branch information
jklamer authored and mgcuthbert committed Apr 26, 2018
1 parent 23b9c0a commit 1d02130
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ repositories
// For Spark CDH
maven { url "https://repository.cloudera.com/content/repositories/releases/" }
// For jetty (through spark)
maven { url "http://repo.spring.io/plugins-release/" }
maven { url "http://repository.cloudera.com/cloudera/cloudera-repos/" }
}

idea {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void addObject(final AtlasObject object)
{
if (object instanceof LocationItem)
{
this.flaggedObjects.add(new FlaggedPoint(((LocationItem) object).getLocation()));
this.flaggedObjects.add(new FlaggedPoint((LocationItem) object));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
public abstract class FlaggedObject implements Serializable
{
protected static final String COUNTRY_MISSING = "NA";
protected static final String AREA_TAG = "Area";
protected static final String EDGE_TAG = "Edge";
protected static final String OSM_IDENTIFIER_TAG = "osmid";
protected static final String ITEM_IDENTIFIER_TAG = "ItemId";
protected static final String ITEM_TYPE_TAG = "ItemType";
protected static final String LINE_TAG = "Line";
protected static final String NODE_TAG = "Node";
protected static final String POINT_TAG = "Point";
private static final long serialVersionUID = -2898518269816777421L;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import java.util.Map;

import org.openstreetmap.atlas.geography.Location;
import org.openstreetmap.atlas.geography.atlas.items.LocationItem;
import org.openstreetmap.atlas.geography.atlas.items.Node;
import org.openstreetmap.atlas.geography.atlas.items.Point;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* A flag for a {@code point} {@link Location} P*
Expand All @@ -13,17 +18,27 @@
public class FlaggedPoint extends FlaggedObject
{
private static final long serialVersionUID = -5912453173756416690L;
private static final Logger logger = LoggerFactory.getLogger(FlaggedPoint.class);
private final Location point;
private final Map<String, String> properties;

/**
* Default constructor
*
* @param point
* the {@code point} {@link Location} to flag
* @param locationItem
* the {@link LocationItem} to flag
*/
public FlaggedPoint(final LocationItem locationItem)
{
this.point = locationItem.getLocation();
this.properties = initProperties(locationItem);
}

@SuppressWarnings("unchecked")
public FlaggedPoint(final Location point)
{
this.point = point;
this.properties = Collections.EMPTY_MAP;
}

@Override
Expand All @@ -36,6 +51,27 @@ public Iterable<Location> getGeometry()
@Override
public Map<String, String> getProperties()
{
return Collections.EMPTY_MAP;
return this.properties;
}

@SuppressWarnings("unchecked")
private Map<String, String> initProperties(final LocationItem locationItem)
{
final Map<String, String> tags = locationItem.getTags();
tags.put(ITEM_IDENTIFIER_TAG, locationItem.getIdentifier() + "");
tags.put(OSM_IDENTIFIER_TAG, locationItem.getOsmIdentifier() + "");
if (locationItem instanceof Node)
{
tags.put(ITEM_TYPE_TAG, NODE_TAG);
}
else if (locationItem instanceof Point)
{
tags.put(ITEM_TYPE_TAG, POINT_TAG);
}
else
{
logger.warn("Flagged LocationItem with unknown item type {}", locationItem);
}
return tags;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@
public class FlaggedPolyline extends FlaggedObject
{
private static final long serialVersionUID = -1184306312148054279L;
private static final String AREA_TAG = "Area";
private static final String EDGE_TAG = "Edge";
private static final String OSM_IDENTIFIER_TAG = "osmid";
private static final String ITEM_IDENTIFIER_TAG = "ItemId";
private static final String ITEM_TYPE_TAG = "ItemType";
private static final String LINE_TAG = "Line";
private static final String NODE_TAG = "Node";
private static final String POINT_TAG = "Point";

private final String country;
private final PolyLine polyLine;
Expand Down

0 comments on commit 1d02130

Please sign in to comment.