public class GeomapsPlugin extends PluginActivator implements GeomapsService, PostCreateTopicListener, PostUpdateTopicListener, PreSendTopicListener
Modifier and Type | Class and Description |
---|---|
private class |
GeomapsPlugin.Address |
Modifier and Type | Field and Description |
---|---|
private ContextTracker |
contextTracker |
private static String |
COOKIE_NO_GEOCODING |
private static double |
EARTH_RADIUS_KM |
private FacetsService |
facetsService |
private static String |
GEOCODER_URL |
private Logger |
logger |
private TopicmapsService |
topicmapsService |
bundle, dmx, mf
Constructor and Description |
---|
GeomapsPlugin() |
Modifier and Type | Method and Description |
---|---|
private boolean |
abortGeocoding(Topic address) |
private boolean |
abortGeocodingByCookie(Topic address) |
private boolean |
abortGeocodingByExcecutionContext(Topic address) |
void |
addCoordinateToGeomap(long geomapId,
long geoCoordId)
Adds a Geo Coordinate topic to a geomap.
|
private void |
geocodeAndStoreFacet(GeomapsPlugin.Address address,
Topic topic)
Geocodes the given address and stores the resulting coordinate as a facet value of the given Address topic.
|
GeoCoordinate |
geoCoordinate(Topic geoCoordTopic)
Returns the geo coordinate encoded in a Geo Coordinate topic.
|
double |
getDistance(GeoCoordinate coord1,
GeoCoordinate coord2)
Calculates the distance between 2 geo coordinates in kilometer.
|
Topic |
getDomainTopic(long geoCoordId)
Finds the domain topic that corresponds to a Geo Coordinate topic.
|
GeoCoordinate |
getGeoCoordinate(Topic geoTopic)
Returns the geo coordinate of a geo-facetted topic (e.g.
|
private Topic |
getGeoCoordinateTopic(Topic geoTopic)
Returns the Geo Coordinate topic (including its child topics) of a geo-facetted topic (e.g.
|
Geomap |
getGeomap(long geomapId) |
void |
init() |
void |
postCreateTopic(Topic topic) |
void |
postUpdateTopic(Topic topic,
TopicModel updateModel,
TopicModel oldTopic) |
void |
preSendTopic(Topic topic)
Enriches an Address topic with its geo coordinate.
|
<V> V |
runWithoutGeocoding(Callable<V> callable)
Executes the passed codeblock and suppresses geocoding for Address topics created/updated while execution.
|
void |
setGeomapState(long geomapId,
double lon,
double lat,
int zoom) |
private void |
storeGeoCoordinate(Topic address,
GeoCoordinate geoCoord)
Stores a geo coordinate for an address topic in the DB.
|
getBundleContext, getPluginName, getStaticResource, getUri, preInstall, publishFileSystem, serviceArrived, serviceGone, setCoreService, shutdown, start, stop, toString
private static final String GEOCODER_URL
private static final String COOKIE_NO_GEOCODING
private static final double EARTH_RADIUS_KM
private TopicmapsService topicmapsService
private FacetsService facetsService
private ContextTracker contextTracker
public GeomapsPlugin()
public Geomap getGeomap(long geomapId)
getGeomap
in interface GeomapsService
public Topic getDomainTopic(long geoCoordId)
GeomapsService
getDomainTopic
in interface GeomapsService
public GeoCoordinate getGeoCoordinate(Topic geoTopic)
GeomapsService
null
if no geo coordinate is stored.getGeoCoordinate
in interface GeomapsService
null
.public GeoCoordinate geoCoordinate(Topic geoCoordTopic)
GeomapsService
geoCoordinate
in interface GeomapsService
public void addCoordinateToGeomap(long geomapId, long geoCoordId)
GeomapsService
addCoordinateToGeomap
in interface GeomapsService
public void setGeomapState(long geomapId, double lon, double lat, int zoom)
setGeomapState
in interface GeomapsService
public double getDistance(GeoCoordinate coord1, GeoCoordinate coord2)
GeomapsService
getDistance
in interface GeomapsService
public <V> V runWithoutGeocoding(Callable<V> callable) throws Exception
GeomapsService
runWithoutGeocoding
in interface GeomapsService
Exception
public void init()
init
in interface PluginContext
init
in class PluginActivator
public void postCreateTopic(Topic topic)
postCreateTopic
in interface PostCreateTopicListener
public void postUpdateTopic(Topic topic, TopicModel updateModel, TopicModel oldTopic)
postUpdateTopic
in interface PostUpdateTopicListener
public void preSendTopic(Topic topic)
preSendTopic
in interface PreSendTopicListener
private Topic getGeoCoordinateTopic(Topic geoTopic)
null
if no geo coordinate is stored.private void geocodeAndStoreFacet(GeomapsPlugin.Address address, Topic topic)
topic
- the Address topic to be facetted.private void storeGeoCoordinate(Topic address, GeoCoordinate geoCoord)
private boolean abortGeocoding(Topic address)
private boolean abortGeocodingByCookie(Topic address)
private boolean abortGeocodingByExcecutionContext(Topic address)
Copyright © 2018. All Rights Reserved.