001package systems.dmx.geomaps;
002
003import systems.dmx.geomaps.model.GeoCoordinate;
004import systems.dmx.geomaps.model.Geomap;
005import systems.dmx.core.Topic;
006
007import java.util.concurrent.Callable;
008
009
010
011public interface GeomapsService {
012
013    Geomap getGeomap(long geomapId);
014
015    /**
016     * Finds the domain topic that corresponds to a Geo Coordinate topic.
017     */
018    Topic getDomainTopic(long geoCoordId);
019
020    /**
021     * Returns the geo coordinate of a geo-facetted topic (e.g. an Address),
022     * or <code>null</code> if no geo coordinate is stored.
023     *
024     * @return  the geo coordinate, or <code>null</code>.
025     */
026    GeoCoordinate getGeoCoordinate(Topic geoTopic);
027
028    /**
029     * Returns the geo coordinate encoded in a Geo Coordinate topic.
030     */
031    GeoCoordinate geoCoordinate(Topic geoCoordTopic);
032
033    /**
034     * Adds a Geo Coordinate topic to a geomap.
035     */
036    void addCoordinateToGeomap(long geomapId, long geoCoordId);
037
038    void setGeomapState(long geomapId, double lon, double lat, int zoom);
039
040    /**
041     * Calculates the distance between 2 geo coordinates in kilometer.
042     */
043    double getDistance(GeoCoordinate coord1, GeoCoordinate coord2);
044
045    // ---
046
047    /**
048     * Executes the passed codeblock and suppresses geocoding for Address topics created/updated while execution.
049     *
050     * @return  the value returned by the codeblock.
051     */
052    <V> V runWithoutGeocoding(Callable<V> callable) throws Exception;
053}