org.opentripplanner.ext.vectortiles.PropertyMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
package org.opentripplanner.ext.vectortiles;
import com.wdtinc.mapbox_vector_tile.VectorTile;
import com.wdtinc.mapbox_vector_tile.adapt.jts.IUserDataConverter;
import com.wdtinc.mapbox_vector_tile.adapt.jts.UserDataKeyValueMapConverter;
import com.wdtinc.mapbox_vector_tile.build.MvtLayerProps;
import java.util.Collection;
import org.opentripplanner.common.model.T2;
/**
* This class is used for adding data for each object in the vector layer from the userData in the
* geometry.
*
* @param is type of userData in the geometry.
* @see UserDataKeyValueMapConverter
*/
public abstract class PropertyMapper implements IUserDataConverter {
public void addTags(
Object userData,
MvtLayerProps layerProps,
VectorTile.Tile.Feature.Builder featureBuilder
) {
if (userData != null) {
for (T2 e : map((T) userData)) {
final String key = e.first;
final Object value = e.second;
if (key != null && value != null) {
final int valueIndex = layerProps.addValue(value);
if (valueIndex >= 0) {
featureBuilder.addTags(layerProps.addKey(key));
featureBuilder.addTags(valueIndex);
}
}
}
}
}
/**
* The return type is to allow null values.
*/
protected abstract Collection> map(T input);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy