Commit ff9390fe authored by Jörg Richter's avatar Jörg Richter
Browse files

Extend `GeomapsService` by `geocodeAndStoreFacet()` (#2)

parent a37fcd45
Pipeline #12296 passed with stages
in 43 seconds
......@@ -163,6 +163,22 @@ public class GeomapsPlugin extends PluginActivator implements GeomapsService, Ge
}
}
// Note: not RESTful. Needed by Migration3.
@Override
public void geocodeAndStoreFacet(Topic addressTopic) {
facetsService.addFacetTypeToTopic(addressTopic.getId(), GEO_COORDINATE_FACET);
//
Address address = new Address(addressTopic /* .getChildTopics().getModel() */); // ### TODO
if (!address.isEmpty()) {
logger.info("### New " + address);
_geocodeAndStoreFacet(address, addressTopic);
} else {
// Never happens in DMX. Note: the storage layer never creates empty composites. If all
// Address fields are left empty no Address topic is created in the first place.
logger.info("New empty address");
}
}
@GET
@Path("/distance")
@Override
......@@ -285,18 +301,6 @@ public class GeomapsPlugin extends PluginActivator implements GeomapsService, Ge
// ---
private void geocodeAndStoreFacet(Topic addressTopic) {
facetsService.addFacetTypeToTopic(addressTopic.getId(), GEO_COORDINATE_FACET);
//
Address address = new Address(addressTopic /* .getChildTopics().getModel() */); // ### TODO
if (!address.isEmpty()) {
logger.info("### New " + address);
_geocodeAndStoreFacet(address, addressTopic);
} else {
logger.info("New empty address");
}
}
/**
* Geocodes the given address and stores the resulting coordinate as a facet value of the given Address topic.
* If geocoding (or storing the coordinate) fails a warning is logged; no exception is thrown.
......
......@@ -36,6 +36,11 @@ public interface GeomapsService {
void setGeomapState(long geomapId, double lon, double lat, double zoom);
/**
* Geocodes the given address and stores the resulting coordinate as a facet value of the given Address topic.
*/
void geocodeAndStoreFacet(Topic addressTopic);
/**
* Calculates the distance between 2 geo coordinates in kilometer.
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment