use of org.vitrivr.cineast.core.data.providers.primitive.FloatArrayTypeProvider 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);
}
use of org.vitrivr.cineast.core.data.providers.primitive.FloatArrayTypeProvider in project cineast by vitrivr.
the class StringFloatArrayPair method convert.
@Override
public Map<String, PrimitiveTypeProvider> convert(StringFloatArrayPair data) {
HashMap<String, PrimitiveTypeProvider> map = new HashMap<>(2);
map.put("id", new StringTypeProvider(data.id));
map.put("feature", new FloatArrayTypeProvider(data.vector));
return map;
}
Aggregations