You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@baremaps.apache.org by "Perdjesk (via GitHub)" <gi...@apache.org> on 2023/07/13 11:37:14 UTC

[GitHub] [incubator-baremaps] Perdjesk opened a new pull request, #724: IPLoc precision levels, add metadata fields in iploc database

Perdjesk opened a new pull request, #724:
URL: https://github.com/apache/incubator-baremaps/pull/724

   Goals:
   - Introduce levels of precision in IPLoc
   - Reduce possible impactful errors when searching Geocoder
   - Scope errors when using Geocoder within a country
   - Fallback to WORLD when not enough info is present
   - Add some metadata fields to understand the index creation


-- 
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: commits-unsubscribe@baremaps.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-baremaps] bchapuis commented on a diff in pull request #724: IPLoc precision levels, add metadata fields in iploc database

Posted by "bchapuis (via GitHub)" <gi...@apache.org>.
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: commits-unsubscribe@baremaps.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-baremaps] bchapuis commented on a diff in pull request #724: IPLoc precision levels, add metadata fields in iploc database

Posted by "bchapuis (via GitHub)" <gi...@apache.org>.
bchapuis commented on code in PR #724:
URL: https://github.com/apache/incubator-baremaps/pull/724#discussion_r1262460197


##########
baremaps-core/src/main/java/org/apache/baremaps/iploc/IpLocObject.java:
##########
@@ -20,6 +20,10 @@ public record IpLocObject(
     InetRange inetRange,
     Coordinate coordinate,
     String network,
-    String country) {
+    String country,
+
+    String source,
+
+    String precision) {

Review Comment:
   Would it make sense to use an enum for the precision?



##########
baremaps-core/src/main/java/org/apache/baremaps/geocoder/GeonamesDocumentMapper.java:
##########
@@ -35,13 +35,14 @@ public Document apply(GeonamesRecord record) {
     document.add(new StoredField("latitude", record.getLatitude()));
     document.add(new StoredField("asciiname", record.getAsciiname()));
     document.add(new StoredField("alternatenames", record.getAlternatenames()));
-    document.add(new StoredField("featureClass", record.getFeatureClass()));
+    document.add(new StringField("featureClass", record.getFeatureClass(), Field.Store.YES));

Review Comment:
   Out of curiosity, why is the StringField better in this case?



##########
baremaps-server/src/main/java/org/apache/baremaps/server/GeocoderResource.java:
##########
@@ -54,15 +54,16 @@ public GeocoderResource(SearcherManager searcherManager) {
 
   @GET
   @javax.ws.rs.Path("/api/geocoder")
-  public Response getIpToLocation(
+  public Response searchLocations(
       @QueryParam("queryText") String queryText,
       @QueryParam("countryCode") @DefaultValue("") String countryCode,
       @QueryParam("limit") @DefaultValue("10") int limit) throws IOException {
     if (queryText == null) {
       throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST)
           .entity("The queryText parameter is mandatory").build());
     }
-    var query = new GeonamesQueryBuilder().queryText(queryText).countryCode(countryCode).build();
+    var query = new GeonamesQueryBuilder()
+        .queryText(queryText).countryCode(countryCode).withScoringByPopulation().build();

Review Comment:
   Should we use the key word "with" before each method? e.g. withQueryText.



-- 
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: commits-unsubscribe@baremaps.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-baremaps] sonarcloud[bot] commented on pull request #724: IPLoc precision levels, add metadata fields in iploc database

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #724:
URL: https://github.com/apache/incubator-baremaps/pull/724#issuecomment-1641774144

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_baremaps&pullRequest=724)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_baremaps&pullRequest=724&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_baremaps&pullRequest=724&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_baremaps&pullRequest=724&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_baremaps&pullRequest=724) No Coverage information  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_baremaps&pullRequest=724&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_baremaps&pullRequest=724&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: commits-unsubscribe@baremaps.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-baremaps] sonarcloud[bot] commented on pull request #724: IPLoc precision levels, add metadata fields in iploc database

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #724:
URL: https://github.com/apache/incubator-baremaps/pull/724#issuecomment-1634135652

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_baremaps&pullRequest=724)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_baremaps&pullRequest=724&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_baremaps&pullRequest=724&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_baremaps&pullRequest=724&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_baremaps&pullRequest=724) No Coverage information  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_baremaps&pullRequest=724&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_baremaps&pullRequest=724&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: commits-unsubscribe@baremaps.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-baremaps] bchapuis commented on a diff in pull request #724: IPLoc precision levels, add metadata fields in iploc database

Posted by "bchapuis (via GitHub)" <gi...@apache.org>.
bchapuis commented on code in PR #724:
URL: https://github.com/apache/incubator-baremaps/pull/724#discussion_r1262463099


##########
baremaps-core/src/main/java/org/apache/baremaps/geocoder/GeonamesDocumentMapper.java:
##########
@@ -35,13 +35,14 @@ public Document apply(GeonamesRecord record) {
     document.add(new StoredField("latitude", record.getLatitude()));
     document.add(new StoredField("asciiname", record.getAsciiname()));
     document.add(new StoredField("alternatenames", record.getAlternatenames()));
-    document.add(new StoredField("featureClass", record.getFeatureClass()));
+    document.add(new StringField("featureClass", record.getFeatureClass(), Field.Store.YES));

Review Comment:
   Out of curiosity, why is the StringField better in this case?



-- 
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: commits-unsubscribe@baremaps.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-baremaps] bchapuis commented on pull request #724: IPLoc precision levels, add metadata fields in iploc database

Posted by "bchapuis (via GitHub)" <gi...@apache.org>.
bchapuis commented on PR #724:
URL: https://github.com/apache/incubator-baremaps/pull/724#issuecomment-1635876932

   Just noticed that the formatting and javadoc must be fixed before merging. Thanks a lot for your work!


-- 
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: commits-unsubscribe@baremaps.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-baremaps] Perdjesk commented on a diff in pull request #724: IPLoc precision levels, add metadata fields in iploc database

Posted by "Perdjesk (via GitHub)" <gi...@apache.org>.
Perdjesk commented on code in PR #724:
URL: https://github.com/apache/incubator-baremaps/pull/724#discussion_r1267837641


##########
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:
   Done in https://github.com/apache/incubator-baremaps/commit/5caf68cbe7d30f290bf2e61568bb7876758a347a



-- 
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: commits-unsubscribe@baremaps.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-baremaps] Perdjesk commented on a diff in pull request #724: IPLoc precision levels, add metadata fields in iploc database

Posted by "Perdjesk (via GitHub)" <gi...@apache.org>.
Perdjesk commented on code in PR #724:
URL: https://github.com/apache/incubator-baremaps/pull/724#discussion_r1267836243


##########
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:
   replaced usage of apache-commons with already used guava dependency in baremaps-core 5caf68cbe7d30f290bf2e61568bb7876758a347a



-- 
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: commits-unsubscribe@baremaps.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-baremaps] sonarcloud[bot] commented on pull request #724: IPLoc precision levels, add metadata fields in iploc database

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #724:
URL: https://github.com/apache/incubator-baremaps/pull/724#issuecomment-1642001323

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_baremaps&pullRequest=724)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_baremaps&pullRequest=724&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_baremaps&pullRequest=724&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_baremaps&pullRequest=724&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_baremaps&pullRequest=724) No Coverage information  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_baremaps&pullRequest=724&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_baremaps&pullRequest=724&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: commits-unsubscribe@baremaps.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-baremaps] sonarcloud[bot] commented on pull request #724: IPLoc precision levels, add metadata fields in iploc database

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #724:
URL: https://github.com/apache/incubator-baremaps/pull/724#issuecomment-1634152656

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_baremaps&pullRequest=724)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_baremaps&pullRequest=724&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_baremaps&pullRequest=724&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_baremaps&pullRequest=724&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_baremaps&pullRequest=724&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_baremaps&pullRequest=724) No Coverage information  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_baremaps&pullRequest=724&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_baremaps&pullRequest=724&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: commits-unsubscribe@baremaps.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-baremaps] Perdjesk commented on a diff in pull request #724: IPLoc precision levels, add metadata fields in iploc database

Posted by "Perdjesk (via GitHub)" <gi...@apache.org>.
Perdjesk commented on code in PR #724:
URL: https://github.com/apache/incubator-baremaps/pull/724#discussion_r1267836684


##########
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:
   https://github.com/apache/incubator-baremaps/pull/724#discussion_r1267836243



-- 
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: commits-unsubscribe@baremaps.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-baremaps] bchapuis merged pull request #724: IPLoc precision levels, add metadata fields in iploc database

Posted by "bchapuis (via GitHub)" <gi...@apache.org>.
bchapuis merged PR #724:
URL: https://github.com/apache/incubator-baremaps/pull/724


-- 
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: commits-unsubscribe@baremaps.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-baremaps] Perdjesk commented on a diff in pull request #724: IPLoc precision levels, add metadata fields in iploc database

Posted by "Perdjesk (via GitHub)" <gi...@apache.org>.
Perdjesk commented on code in PR #724:
URL: https://github.com/apache/incubator-baremaps/pull/724#discussion_r1267834691


##########
baremaps-server/src/main/java/org/apache/baremaps/server/GeocoderResource.java:
##########
@@ -54,15 +54,16 @@ public GeocoderResource(SearcherManager searcherManager) {
 
   @GET
   @javax.ws.rs.Path("/api/geocoder")
-  public Response getIpToLocation(
+  public Response searchLocations(
       @QueryParam("queryText") String queryText,
       @QueryParam("countryCode") @DefaultValue("") String countryCode,
       @QueryParam("limit") @DefaultValue("10") int limit) throws IOException {
     if (queryText == null) {
       throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST)
           .entity("The queryText parameter is mandatory").build());
     }
-    var query = new GeonamesQueryBuilder().queryText(queryText).countryCode(countryCode).build();
+    var query = new GeonamesQueryBuilder()
+        .queryText(queryText).countryCode(countryCode).withScoringByPopulation().build();

Review Comment:
   dropped the usage of prefix "with" to match builder naming based on field names. 5caf68cbe7d30f290bf2e61568bb7876758a347a



-- 
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: commits-unsubscribe@baremaps.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org