Open llazbal opened 8 years ago
This seems like a band-aid. Should the fix be in the DAO and/or the harvester?
Well, the idea is that the coordinates of the publishing institution should be an obligational field.
The problem is that it is not is treated like such in the harvester, when the user should be asked to provided the coordinates under publisher information.
Alhough, I believe it is also proper programming to prevent such errors with that conditional Leo suggested.
In addition, we can improve my purpose creating the mark only if the coordinates exists, so: <#if (publisher.decimallatitude()?has_content) && (publisher.decimallongitude()?has_content)> <#assign latitude = publisher.decimallatitude()?string?replace(",",".")> <#assign longitude = publisher.decimallongitude()?string?replace(",",".")> <#assign link = "<a href=" + "'" + rc.getMessage("publisherspage.publisherlink.map") + publisher.getAuto_id() + "'" + ">" + publisher.getName() + ""> <#assign popuptxt = "" + rc.getMessage("publisherspage.recordnumber") + " " + publisher.getRecord_count()?string> new L.marker([${latitude}, ${longitude}], {icon: institute}).bindPopup("${link} ${popuptxt}").addTo(map); </#if>
...there is no reason to create an incorrect mark.
I agree Leo, unless the fields are NOT NULL in the database NULL must be handled in the FTL template.
Some comments:
-You don't need a variable to hold latitude and longitude, use ${publisher.decimallatitude?c}
directly
-Use the variable name in Freemarker (the getter is called automatically), publisher.getName()
should be publisher.name
.
When the latitude and/or longitude values are null an exception occurs when try to create the L.marker object. To resolve it we must include conditionals to set the coordinates data, starting at 43 line, the code could be: <#if (publisher.getDecimallatitude()?has_content)> <#assign latitude = publisher.getDecimallongitude()?string?replace(",",".")> <#else> <#assign latitude = 0> </#if> <#if (publisher.getDecimallongitude()?has_content)> <#assign longitude = publisher.getDecimallongitude()?string?replace(",",".")> <#else> <#assign longitude = 0> </#if>