Class Layer
- java.lang.Object
-
- org.openstreetmap.josm.data.imagery.vectortile.mapbox.Layer
-
- All Implemented Interfaces:
Destroyable
public final class Layer extends Object implements Destroyable
A Mapbox Vector Tile Layer- Since:
- 17862
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Layer.ValueFields<T>
-
Field Summary
Fields Modifier and Type Field Description (package private) static int
DEFAULT_EXTENT
The default extent for a vector tileprivate static byte
DEFAULT_VERSION
private int
extent
The extent of the tile, typically 4096.private static byte
EXTENT_FIELD
private static byte
FEATURE_FIELD
private List<Feature>
featureCollection
The actual features of this layer in this tileprivate static byte
KEY_FIELD
private List<String>
keyList
A list of unique keys.static byte
LAYER_FIELD
The field value for a layer (inProtobufRecord.getField()
)private String
name
A unique name for the layer.private static byte
NAME_FIELD
private static byte
VALUE_FIELD
private List<Object>
valueList
A list of unique values.private byte
version
This is technically an integer, but there are currently only two major versions (1, 2).private static byte
VERSION_FIELD
-
Constructor Summary
Constructors Constructor Description Layer(byte[] bytes)
Create a new layerLayer(Collection<ProtobufRecord> records)
Create a layer from a collection of records
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
Called when the object has been destroyed.boolean
equals(Object other)
private static Collection<ProtobufRecord>
getAllRecords(byte[] bytes)
Get all the records from a array of bytesint
getExtent()
Get the extent of the tileCollection<Feature>
getFeatures()
Get the feature on this layerCollection<Geometry>
getGeometry()
Get the geometry for this layerString
getKey(int index)
Get a specified keyString
getName()
Get the name of the layerObject
getValue(int index)
Get a specified valuebyte
getVersion()
Get the Mapbox Vector Tile version specification for this layerint
hashCode()
-
-
-
Field Detail
-
LAYER_FIELD
public static final byte LAYER_FIELD
The field value for a layer (inProtobufRecord.getField()
)- See Also:
- Constant Field Values
-
VERSION_FIELD
private static final byte VERSION_FIELD
- See Also:
- Constant Field Values
-
NAME_FIELD
private static final byte NAME_FIELD
- See Also:
- Constant Field Values
-
FEATURE_FIELD
private static final byte FEATURE_FIELD
- See Also:
- Constant Field Values
-
KEY_FIELD
private static final byte KEY_FIELD
- See Also:
- Constant Field Values
-
VALUE_FIELD
private static final byte VALUE_FIELD
- See Also:
- Constant Field Values
-
EXTENT_FIELD
private static final byte EXTENT_FIELD
- See Also:
- Constant Field Values
-
DEFAULT_EXTENT
static final int DEFAULT_EXTENT
The default extent for a vector tile- See Also:
- Constant Field Values
-
DEFAULT_VERSION
private static final byte DEFAULT_VERSION
- See Also:
- Constant Field Values
-
version
private final byte version
This is technically an integer, but there are currently only two major versions (1, 2). Required.
-
name
private final String name
A unique name for the layer. This must be unique on a per-tile basis. Required.
-
extent
private final int extent
The extent of the tile, typically 4096. Required.
-
valueList
private final List<Object> valueList
A list of unique values. Order is important. Optional.
-
featureCollection
private final List<Feature> featureCollection
The actual features of this layer in this tile
-
-
Constructor Detail
-
Layer
public Layer(Collection<ProtobufRecord> records) throws IOException
Create a layer from a collection of records- Parameters:
records
- The records to convert to a layer- Throws:
IOException
- - if an IO error occurs
-
Layer
public Layer(byte[] bytes) throws IOException
Create a new layer- Parameters:
bytes
- The bytes that the layer comes from- Throws:
IOException
- - if an IO error occurs
-
-
Method Detail
-
getAllRecords
private static Collection<ProtobufRecord> getAllRecords(byte[] bytes) throws IOException
Get all the records from a array of bytes- Parameters:
bytes
- The byte information- Returns:
- All the protobuf records
- Throws:
IOException
- If there was an error reading the bytes (unlikely)
-
getExtent
public int getExtent()
Get the extent of the tile- Returns:
- The layer extent
-
getFeatures
public Collection<Feature> getFeatures()
Get the feature on this layer- Returns:
- the features
-
getGeometry
public Collection<Geometry> getGeometry()
Get the geometry for this layer- Returns:
- The geometry
-
getKey
public String getKey(int index)
Get a specified key- Parameters:
index
- The index in the key list- Returns:
- The actual key
-
getVersion
public byte getVersion()
Get the Mapbox Vector Tile version specification for this layer- Returns:
- The version of the Mapbox Vector Tile specification
-
destroy
public void destroy()
Description copied from interface:Destroyable
Called when the object has been destroyed.- Specified by:
destroy
in interfaceDestroyable
-
-