Search in sources :

Example 1 with Location

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);
}
Also used : HashMap(java.util.HashMap) FloatArrayTypeProvider(org.vitrivr.cineast.core.data.providers.primitive.FloatArrayTypeProvider) PrimitiveTypeProvider(org.vitrivr.cineast.core.data.providers.primitive.PrimitiveTypeProvider) Location(org.vitrivr.cineast.core.data.Location)

Aggregations

HashMap (java.util.HashMap)1 Location (org.vitrivr.cineast.core.data.Location)1 FloatArrayTypeProvider (org.vitrivr.cineast.core.data.providers.primitive.FloatArrayTypeProvider)1 PrimitiveTypeProvider (org.vitrivr.cineast.core.data.providers.primitive.PrimitiveTypeProvider)1