WingLongitude / explorer

Canadensys data portal
MIT License
0 stars 2 forks source link

Null values for coordinates data in publishers.ftl when L.marker object is created #10

Open llazbal opened 8 years ago

llazbal commented 8 years ago

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>

dshorthouse commented 8 years ago

This seems like a band-aid. Should the fix be in the DAO and/or the harvester?

tigreped commented 8 years ago

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.

llazbal commented 8 years ago

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.

cgendreau commented 8 years ago

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.