use of org.vitrivr.cineast.core.data.Location in project cineast by vitrivr.
the class SpatialImporter method parseEntry.
private Optional<Map<String, PrimitiveTypeProvider>> parseEntry(String key, String[] data) {
String lat = data[LSCUtilities.META_LAT_COL];
String lon = data[LSCUtilities.META_LON_COL];
if (LSCUtilities.isAnyMetaBlank(lat, lon)) {
LOGGER.warn("Either lat or long for {} is blank. Ignoring.", key);
return Optional.empty();
}
boolean ignore = false;
float fLat = Float.NaN, fLon = Float.NaN;
try {
fLat = Float.parseFloat(lat);
} catch (NumberFormatException e) {
LOGGER.warn("Could not parse latitute for {}, as it was {}", key, lat, e);
ignore = true;
}
try {
fLon = Float.parseFloat(lon);
} catch (NumberFormatException e) {
LOGGER.warn("Could not parse longitutde for {}, as it was {}", key, lon, e);
ignore = true;
}
if (ignore) {
return Optional.empty();
}
Location location = Location.of(fLat, fLon);
FloatArrayTypeProvider vector = new FloatArrayTypeProvider(ReadableFloatVector.toArray(location));
final HashMap<String, PrimitiveTypeProvider> map = new HashMap<>();
// id
map.put("id", PrimitiveTypeProvider.fromObject(LSCUtilities.pathToSegmentId(key)));
// feature
map.put("feature", vector);
return Optional.of(map);
}
Aggregations