private String determineGeo()

in src/main/java/org/apache/sdap/ningester/writer/SolrStore.java [117:154]


    private String determineGeo(TileSummary summary) {
        //Solr cannot index a POLYGON where all corners are the same point or when there are only 2 distinct points (line).
        //Solr is configured for a specific precision so we need to round to that precision before checking equality.
        Integer geoPrecision = this.geoPrecision;

        BigDecimal latMin = BigDecimal.valueOf(summary.getBbox().getLatMin()).setScale(geoPrecision, BigDecimal.ROUND_HALF_UP);
        BigDecimal latMax = BigDecimal.valueOf(summary.getBbox().getLatMax()).setScale(geoPrecision, BigDecimal.ROUND_HALF_UP);
        BigDecimal lonMin = BigDecimal.valueOf(summary.getBbox().getLonMin()).setScale(geoPrecision, BigDecimal.ROUND_HALF_UP);
        BigDecimal lonMax = BigDecimal.valueOf(summary.getBbox().getLonMax()).setScale(geoPrecision, BigDecimal.ROUND_HALF_UP);

        String geo;
        //If lat min = lat max and lon min = lon max, index the 'geo' bounding box as a POINT instead of a POLYGON
        if (latMin.equals(latMax) && lonMin.equals(lonMax)) {
            geo = "POINT(" + lonMin + " " + latMin + ")";
            log.debug("{}\t{}[{}] geo={}", summary.getTileId(), summary.getGranule(), summary.getSectionSpec(), geo);
        }
        //If lat min = lat max but lon min != lon max, then we essentially have a line.
        else if (latMin.equals(latMax)) {
            geo = "LINESTRING (" + lonMin + " " + latMin + ", " + lonMax + " " + latMin + ")";
            log.debug("{}\t{}[{}] geo={}", summary.getTileId(), summary.getGranule(), summary.getSectionSpec(), geo);
        }
        //Same if lon min = lon max but lat min != lat max
        else if (lonMin.equals(lonMax)) {
            geo = "LINESTRING (" + lonMin + " " + latMin + ", " + lonMin + " " + latMax + ")";
            log.debug("{}\t{}[{}] geo={}", summary.getTileId(), summary.getGranule(), summary.getSectionSpec(), geo);
        }
        //All other cases should use POLYGON
        else {
            geo = "POLYGON((" +
                    lonMin + " " + latMin + ", " +
                    lonMax + " " + latMin + ", " +
                    lonMax + " " + latMax + ", " +
                    lonMin + " " + latMax + ", " +
                    lonMin + " " + latMin + "))";
        }

        return geo;
    }