bchapuis commented on code in PR #724:
URL: 
https://github.com/apache/incubator-baremaps/pull/724#discussion_r1262683718


##########
baremaps-core/src/main/java/org/apache/baremaps/geocoder/GeonamesQueryBuilder.java:
##########
@@ -106,6 +114,11 @@ public Query build() throws ParseException {
       }
     }
 
+    if (!StringUtils.isBlank(featureCode)) {

Review Comment:
   The String object now has an isBlank method.



##########
baremaps-core/src/main/java/org/apache/baremaps/iploc/IpLocMapper.java:
##########
@@ -85,80 +88,68 @@ public Optional<IpLocObject> apply(NicObject nicObject) {
               inetRange,
               location.get(),
               network,
-              attributes.get("country")));
+              attributes.get("country"),
+              attributes.get("source"),
+              IpLocPrecision.COORDINATE,
+              "geoloc"));
         }
       }
 
-      // If there is an address we use that address to query the geocoder
-      if (attributes.containsKey("address")) {
-        var location = findLocation(attributes.get("address"), 
attributes.get("country"));
-        if (location.isPresent()) {
-          return Optional.of(new IpLocObject(
-              attributes.get("address"),
-              inetRange,
-              location.get(),
-              network,
-              attributes.get("country")));
+      // If there is a country, we use that with a cherry-picked list of 
fields to query the
+      // geocoder with confidence to find a relevant precise location,
+      // in the worst case the error is within a country
+      List<String> searchedFields = List.of("descr", "netname");
+      // at least one of a searchedField is present and the country is present.
+      if (attributes.keySet().stream().anyMatch(searchedFields::contains)
+          && attributes.containsKey("country")) {
+        // build a query text string out of the cherry-picked fields
+        var queryTextBuilder = new StringBuilder();
+        for (String field : searchedFields) {
+          if (StringUtils.isNotBlank(attributes.get(field))) {

Review Comment:
   idem



##########
baremaps-core/src/main/java/org/apache/baremaps/iploc/IpLocPrecision.java:
##########
@@ -0,0 +1,17 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not 
use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+
+package org.apache.baremaps.iploc;
+
+public enum IpLocPrecision {
+  COORDINATE, WORLD, COUNTRY

Review Comment:
   We could introduce two levels:
   - Geoloc
   - Geocoder
   - Country
   - World



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to