commit ce5bfed1bc1e0acbf3d58213d02af02e2abc25f5
Author: Jakub Smid <jaksmid@seznam.cz>
Date:   Tue Apr 26 12:20:13 2022 +0200

    Changed coordinates to null from 0.0 when not known
    
    re #9625

diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItem.java b/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItem.java
index b722715..dfd2a79 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItem.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItem.java
@@ -49,17 +49,17 @@ public class CatalogItem {
     /**
      * Certainty
      */
-    private int certainty;
+    private Integer certainty;
 
     /**
      * Longitude
      */
-    private double longitude;
+    private Double longitude;
 
     /**
      * Latitude
      */
-    private double latitude;
+    private Double latitude;
 
     /**
      * Description
@@ -138,21 +138,21 @@ public class CatalogItem {
         this.bibliography = stringList.stream().map(s -> new Bibliography(s, this)).collect(Collectors.toSet());
     }
 
-    private int processIntField(String field) {
+    private Integer processIntField(String field) {
         Matcher matcher = Pattern.compile(INTEGER_PATTERN).matcher(field);
         if (matcher.find()) {
             return Integer.parseInt(matcher.group());
         } else {
-            return 0;
+            return null;
         }
     }
 
-    private double processDoubleField(String field) {
+    private Double processDoubleField(String field) {
         Matcher matcher = Pattern.compile(DOUBLE_PATTERN).matcher(field);
         if (matcher.find()) {
             return Double.parseDouble(matcher.group());
         } else {
-            return 0.0;
+            return null;
         }
     }
 
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItemDto.java b/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItemDto.java
index cf6f2da..e404aa2 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItemDto.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItemDto.java
@@ -55,17 +55,17 @@ public class CatalogItemDto {
     /**
      * Longitude
      */
-    private double longitude;
+    private Double longitude;
 
     /**
      * Latitude
      */
-    private double latitude;
+    private Double latitude;
 
     /**
      * Certainty
      */
-    private int certainty;
+    private Integer certainty;
 
     /**
      * Description
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItemServiceImpl.java b/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItemServiceImpl.java
index 90d192a..671ad92 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItemServiceImpl.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItemServiceImpl.java
@@ -14,7 +14,10 @@ import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
 import java.util.function.Predicate;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -73,10 +76,6 @@ public class CatalogItemServiceImpl implements ICatalogItemService {
      */
     private static final String CATALOG_ITEM_NOT_FOUND = "Catalog item not found";
 
-    /**
-     * Threshold for comparing doubles
-     */
-    private static final double DOUBLE_THRESHOLD = 0.001;
 
     /**
      * Catalog repository
@@ -123,8 +122,6 @@ public class CatalogItemServiceImpl implements ICatalogItemService {
         log.info("Catalog item deleted");
     }
 
-    private final Map<String, AlternativeName> map = new HashMap<>();
-
     @Override
     public CatalogItemDto getCatalogItem(UUID id) {
         CatalogItem catalogItem = catalogItemRepository.findById(id).orElseThrow(() -> {
@@ -171,7 +168,7 @@ public class CatalogItemServiceImpl implements ICatalogItemService {
             } else {
                 List<CatalogItem> foundItems = catalogItemRepository.getItemsByName(textToFind);
                 if (!foundItems.isEmpty()) {
-                    if (foundItems.stream().anyMatch(c -> Math.abs(c.getLatitude()) > DOUBLE_THRESHOLD && Math.abs(c.getLongitude()) > DOUBLE_THRESHOLD)) {
+                    if (foundItems.stream().anyMatch(c -> c.getLatitude() != null && c.getLongitude() != null)) {
                         textToFind = "<span style='color:green'>" + textToFind + "</span>";
                     } else {
                         textToFind = "<span style='color:red'>" + textToFind + "</span>";
diff --git a/backend/src/test/java/cz/zcu/kiv/backendapi/catalog/CatalogItemServiceImplFilterTest.java b/backend/src/test/java/cz/zcu/kiv/backendapi/catalog/CatalogItemServiceImplFilterTest.java
index fcda0bc..21ed37b 100644
--- a/backend/src/test/java/cz/zcu/kiv/backendapi/catalog/CatalogItemServiceImplFilterTest.java
+++ b/backend/src/test/java/cz/zcu/kiv/backendapi/catalog/CatalogItemServiceImplFilterTest.java
@@ -96,7 +96,7 @@ class CatalogItemServiceImplFilterTest {
         catalogItem1.setCountries(Set.of(new Country(countryAaa, catalogItem1), new Country(countryDcd, catalogItem1)));
         catalogItem1.setWrittenForms(Set.of(new WrittenForm(writtenForm, catalogItem1)));
 
-        catalogItemDto1 = new CatalogItemDto(catalogItemId1, nameFirst, Collections.emptySet(), Set.of(writtenForm), Set.of(country, city), Set.of(countryAaa, countryDcd), Collections.emptySet(), 0.0, 0.0, 0, "");
+        catalogItemDto1 = new CatalogItemDto(catalogItemId1, nameFirst, Collections.emptySet(), Set.of(writtenForm), Set.of(country, city), Set.of(countryAaa, countryDcd), Collections.emptySet(), null, null, null, "");
 
         catalogItem2.setName(nameSecond);
         catalogItem2.setAlternativeNames(Set.of(new AlternativeName(nameTwelve, catalogItem2), new AlternativeName(nameThird, catalogItem2)));
@@ -104,7 +104,7 @@ class CatalogItemServiceImplFilterTest {
         catalogItem2.setCountries(Set.of(new Country(countryAaa, catalogItem2), new Country(countryBbb, catalogItem2)));
         catalogItem2.setWrittenForms(Set.of(new WrittenForm(writtenFormUpper, catalogItem2)));
 
-        catalogItemDto2 = new CatalogItemDto(catalogItemId2, nameSecond, Set.of(nameTwelve, nameThird), Set.of(writtenFormUpper), Set.of(country, cityUpper), Set.of(countryAaa, countryBbb), Collections.emptySet(), 0.0, 0.0, 0, "");
+        catalogItemDto2 = new CatalogItemDto(catalogItemId2, nameSecond, Set.of(nameTwelve, nameThird), Set.of(writtenFormUpper), Set.of(country, cityUpper), Set.of(countryAaa, countryBbb), Collections.emptySet(), null, null, null, "");
 
         catalogItem3.setName(nameThird);
         catalogItem3.setAlternativeNames(Set.of(new AlternativeName(nameTwentyUpper, catalogItem3), new AlternativeName(nameSedond, catalogItem3)));
@@ -112,20 +112,20 @@ class CatalogItemServiceImplFilterTest {
         catalogItem3.setCountries(Set.of(new Country(countryAaaUpper, catalogItem3), new Country(countryCcc, catalogItem3)));
         catalogItem3.setWrittenForms(Set.of(new WrittenForm(writtenFormForOr, catalogItem3)));
 
-        catalogItemDto3 = new CatalogItemDto(catalogItemId3, nameThird, Set.of(nameTwentyUpper, nameSedond), Set.of(writtenFormForOr), Set.of(countri, capitalCityNew), Set.of(countryAaaUpper, countryCcc), Collections.emptySet(), 0.0, 0.0, 0, "");
+        catalogItemDto3 = new CatalogItemDto(catalogItemId3, nameThird, Set.of(nameTwentyUpper, nameSedond), Set.of(writtenFormForOr), Set.of(countri, capitalCityNew), Set.of(countryAaaUpper, countryCcc), Collections.emptySet(), null, null, null, "");
 
         catalogItem4.setAlternativeNames(Set.of(new AlternativeName(nameTwelve, catalogItem4), new AlternativeName(nameFirstUpper, catalogItem4)));
         catalogItem4.setTypes(Set.of(typeCountri, typeCountry));
         catalogItem4.setCountries(Set.of(new Country(countryBccb, catalogItem4), new Country(countryDdd, catalogItem4)));
         catalogItem4.setWrittenForms(Set.of(new WrittenForm(writtenForm, catalogItem4), new WrittenForm(writtenFormForOr, catalogItem4)));
 
-        catalogItemDto4 = new CatalogItemDto(catalogItemId4, "", Set.of(nameTwelve, nameFirstUpper), Set.of(writtenForm, writtenFormForOr), Set.of(countri, country), Set.of(countryBccb, countryDdd), Collections.emptySet(), 0.0, 0.0, 0, "");
+        catalogItemDto4 = new CatalogItemDto(catalogItemId4, "", Set.of(nameTwelve, nameFirstUpper), Set.of(writtenForm, writtenFormForOr), Set.of(countri, country), Set.of(countryBccb, countryDdd), Collections.emptySet(), null, null, null, "");
 
         catalogItem5.setName(nameSedond);
         catalogItem5.setAlternativeNames(Set.of(new AlternativeName(nameThird, catalogItem5)));
         catalogItem5.setTypes(Set.of(typeCountri));
 
-        catalogItemDto5 = new CatalogItemDto(catalogItemId5, nameSedond, Set.of(nameThird), Collections.emptySet(), Set.of(countri), Collections.emptySet(), Collections.emptySet(), 0.0, 0.0, 0, "");
+        catalogItemDto5 = new CatalogItemDto(catalogItemId5, nameSedond, Set.of(nameThird), Collections.emptySet(), Set.of(countri), Collections.emptySet(), Collections.emptySet(), null, null, null, "");
 
         given(catalogItemRepository.findAll()).willReturn(List.of(catalogItem1, catalogItem2, catalogItem3, catalogItem4, catalogItem5));
     }
diff --git a/backend/src/test/java/cz/zcu/kiv/backendapi/catalog/CatalogItemServiceImplTest.java b/backend/src/test/java/cz/zcu/kiv/backendapi/catalog/CatalogItemServiceImplTest.java
index 9f0ab48..ffdc26c 100644
--- a/backend/src/test/java/cz/zcu/kiv/backendapi/catalog/CatalogItemServiceImplTest.java
+++ b/backend/src/test/java/cz/zcu/kiv/backendapi/catalog/CatalogItemServiceImplTest.java
@@ -311,69 +311,69 @@ class CatalogItemServiceImplTest {
 
         CatalogItem catalogItem1 = new CatalogItem();
         catalogItem1.setAlternativeNames(Stream.of(new AlternativeName("Azbar", catalogItem1)).collect(Collectors.toSet()));
-        catalogItem1.setLatitude(5);
-        catalogItem1.setLongitude(5);
+        catalogItem1.setLatitude(5.0);
+        catalogItem1.setLongitude(5.0);
 
         CatalogItem catalogItem2 = new CatalogItem();
         catalogItem2.setAlternativeNames(Stream.of(new AlternativeName("Azbar", catalogItem2), new AlternativeName("Azbarasdf", catalogItem2)).collect(Collectors.toSet()));
-        catalogItem2.setLatitude(0.0);
-        catalogItem2.setLongitude(0.0);
+        catalogItem2.setLatitude(null);
+        catalogItem2.setLongitude(null);
 
         CatalogItem catalogItem3 = new CatalogItem();
         catalogItem3.setAlternativeNames(Stream.of(new AlternativeName("U-re-me-re", catalogItem3)).collect(Collectors.toSet()));
-        catalogItem3.setLatitude(55);
-        catalogItem3.setLongitude(68);
+        catalogItem3.setLatitude(55.0);
+        catalogItem3.setLongitude(68.0);
 
         CatalogItem catalogItem4 = new CatalogItem();
         catalogItem4.setAlternativeNames(Stream.of(new AlternativeName("Huga", catalogItem4)).collect(Collectors.toSet()));
-        catalogItem4.setLatitude(0.0);
-        catalogItem4.setLongitude(0.0);
+        catalogItem4.setLatitude(null);
+        catalogItem4.setLongitude(null);
 
         CatalogItem catalogItem5 = new CatalogItem();
         catalogItem5.setAlternativeNames(Stream.of(new AlternativeName("Huga", catalogItem5), new AlternativeName("Hugaa", catalogItem5)).collect(Collectors.toSet()));
-        catalogItem5.setLatitude(0.0);
-        catalogItem5.setLongitude(0.0);
+        catalogItem5.setLatitude(null);
+        catalogItem5.setLongitude(null);
 
         CatalogItem catalogItem6 = new CatalogItem();
         catalogItem6.setAlternativeNames(Stream.of(new AlternativeName("Duga", catalogItem6)).collect(Collectors.toSet()));
-        catalogItem6.setLatitude(0.0);
-        catalogItem6.setLongitude(0.0);
+        catalogItem6.setLatitude(null);
+        catalogItem6.setLongitude(null);
 
         CatalogItemDto catalogItemDto1 = new CatalogItemDto();
         catalogItemDto1.setId(catalogItem1.getId());
         catalogItemDto1.setAlternativeNames(Stream.of("Azbar").collect(Collectors.toSet()));
-        catalogItemDto1.setLatitude(5);
-        catalogItemDto1.setLongitude(5);
+        catalogItemDto1.setLatitude(5.0);
+        catalogItemDto1.setLongitude(5.0);
 
         CatalogItemDto catalogItemDto2 = new CatalogItemDto();
         catalogItemDto2.setId(catalogItem2.getId());
         catalogItemDto2.setAlternativeNames(Stream.of("Azbar", "Azbarasdf").collect(Collectors.toSet()));
-        catalogItemDto2.setLatitude(0.0);
-        catalogItemDto2.setLongitude(0.0);
+        catalogItemDto2.setLatitude(null);
+        catalogItemDto2.setLongitude(null);
 
         CatalogItemDto catalogItemDto3 = new CatalogItemDto();
         catalogItemDto3.setId(catalogItem3.getId());
         catalogItemDto3.setAlternativeNames(Stream.of("U-re-me-re").collect(Collectors.toSet()));
-        catalogItemDto3.setLatitude(55);
-        catalogItemDto3.setLongitude(68);
+        catalogItemDto3.setLatitude(55.0);
+        catalogItemDto3.setLongitude(68.0);
 
         CatalogItemDto catalogItemDto4 = new CatalogItemDto();
         catalogItemDto4.setId(catalogItem4.getId());
         catalogItemDto4.setAlternativeNames(Stream.of("Huga").collect(Collectors.toSet()));
-        catalogItemDto4.setLatitude(0.0);
-        catalogItemDto4.setLongitude(0.0);
+        catalogItemDto4.setLatitude(null);
+        catalogItemDto4.setLongitude(null);
 
         CatalogItemDto catalogItemDto5 = new CatalogItemDto();
         catalogItemDto5.setId(catalogItem5.getId());
         catalogItemDto5.setAlternativeNames(Stream.of("Huga", "Hugaa").collect(Collectors.toSet()));
-        catalogItemDto5.setLatitude(0.0);
-        catalogItemDto5.setLongitude(0.0);
+        catalogItemDto5.setLatitude(null);
+        catalogItemDto5.setLongitude(null);
 
         CatalogItemDto catalogItemDto6 = new CatalogItemDto();
         catalogItemDto6.setId(catalogItem6.getId());
         catalogItemDto6.setAlternativeNames(Stream.of("Duga").collect(Collectors.toSet()));
-        catalogItemDto6.setLatitude(0.0);
-        catalogItemDto6.setLongitude(0.0);
+        catalogItemDto6.setLatitude(null);
+        catalogItemDto6.setLongitude(null);
 
 
         given(typeService.getAllTypesAsString()).willReturn(Stream.of("city", "ocean").collect(Collectors.toSet()));
diff --git a/backend/src/test/resources/application.properties b/backend/src/test/resources/application.properties
index 40e4da4..0358781 100644
--- a/backend/src/test/resources/application.properties
+++ b/backend/src/test/resources/application.properties
@@ -8,5 +8,5 @@ spring.jpa.generate-ddl=true
 spring.jpa.open-in-view=false
 spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL10Dialect
 spring.jpa.properties.hibernate.format_sql=true
-spring.jpa.show-sql=true
+spring.jpa.show-sql=false
 
