Class GeoCoordinateConverter

java.lang.Object
io.goobi.viewer.controller.GeoCoordinateConverter

public class GeoCoordinateConverter extends Object
Utility methods for converting geo-coordinated between different formats.
Author:
Florian Alpers
  • Field Details

    • POINT_LAT_LNG_PATTERN

      protected static final String POINT_LAT_LNG_PATTERN
      See Also:
    • POLYGON_LAT_LNG_PATTERN

      protected static final String POLYGON_LAT_LNG_PATTERN
      See Also:
    • COMPILED_POINT_PATTERN

      protected static final Pattern COMPILED_POINT_PATTERN
    • COMPILED_POLYGON_PATTERN

      protected static final Pattern COMPILED_POLYGON_PATTERN
  • Constructor Details

    • GeoCoordinateConverter

      public GeoCoordinateConverter()
    • GeoCoordinateConverter

      public GeoCoordinateConverter(String markerTitleConfig)
    • GeoCoordinateConverter

      public GeoCoordinateConverter(Map<String,Metadata> featureTitleConfigs, Map<String,Metadata> entityTitleConfigs)
    • GeoCoordinateConverter

      public GeoCoordinateConverter(HttpServletRequest servletRequest)
  • Method Details

    • getFeaturesFromSolrQuery

      public List<GeoMapFeature> getFeaturesFromSolrQuery(String query, List<String> filterQueries, List<String> coordinateFields, String markerTitleField, boolean aggregateResults) throws PresentationException, IndexUnreachableException
      Collects all point coordinates in the given coordinate fields from solr documents returned by the given solr query.
      Parameters:
      query - Solr query to get documents
      filterQueries - filter for solr query
      coordinateFields - fields containing the coordinate points to collect
      markerTitleField - solr field containing a title for the coordinates
      aggregateResults - if true, group coordinates from child documents under their parent
      Returns:
      a list of GeoMapFeature
      Throws:
      PresentationException
      IndexUnreachableException
    • getFeaturesFromSolrDocs

      public List<GeoMapFeature> getFeaturesFromSolrDocs(List<String> coordinateFields, String markerTitleField, Map<org.apache.solr.common.SolrDocument,List<org.apache.solr.common.SolrDocument>> docs)
    • getSolrFieldsForMainQuery

      public List<String> getSolrFieldsForMainQuery(List<String> coordinateFields, String markerTitleField, boolean aggregateResults)
    • getSolrFieldsForExpandQuery

      public List<String> getSolrFieldsForExpandQuery(List<String> coordinateFields, String markerTitleField)
    • getGeojsonPoints

      public Collection<GeoMapFeature> getGeojsonPoints(org.apache.solr.common.SolrDocument doc, List<org.apache.solr.common.SolrDocument> children, String metadataField, String titleField)
      Collects all point coordinates in the given metadata field within the given solr document.
      Parameters:
      doc - the document containing the coordinates
      children - child Solr documents associated with the parent doc
      metadataField - The name of the solr field to search in
      titleField - solr field containing a title for the coordinates
      Returns:
      Collection
    • getGeojsonPoints

      public Collection<GeoMapFeature> getGeojsonPoints(org.apache.solr.common.SolrDocument doc, String metadataField, String titleField)
    • getGeojsonPoints

      public Collection<GeoMapFeature> getGeojsonPoints(MetadataContainer doc, String metadataField, String titleField)
    • createTitle

      public static de.intranda.metadata.multilanguage.IMetadataValue createTitle(Metadata labelConfig, Map<String,List<de.intranda.metadata.multilanguage.IMetadataValue>> metadata)
    • getFeatures

      public List<GeoMapFeature> getFeatures(List<String> points)
      Generate a list of geoMapFeatures from a list of metadata values which may represent geographic coordinates. The coordinate strings may take one of three forms:
      • Point: 'x y'
      • Polygon: 'POLYGON((x1 y1, x2 y2,...))'
      • Geojon: a json object following the geojson format
      Parameters:
      points - A list of strings that represent two-dimensional coordinates or an array of such.
      Returns:
      The coordinates in form of geoMapFeatures
    • getLocations

      public static List<Location> getLocations(String solrFieldName, org.apache.solr.common.SolrDocumentList results)
      Parses geo-coordinates from all fields of the given name from the given list of SOLR documents.
      Parameters:
      solrFieldName - Name of the SOLR fields to parse
      results - Documents to parse
      Returns:
      A list of geo-coordinates as Location
    • getLocations

      public static List<IArea> getLocations(Object o)
      Parses geo-coordinates from the value of a SOLR field.
      Parameters:
      o - SOLR field value
      Returns:
      a list of IArea representing the locations from the given value