Class Layer
- java.lang.Object
-
- org.openstreetmap.josm.data.imagery.vectortile.mapbox.Layer
-
- All Implemented Interfaces:
Destroyable
public final class Layer extends java.lang.Object implements Destroyable
A Mapbox Vector Tile Layer- Since:
- 17862
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classLayer.ValueFields<T>
-
Field Summary
Fields Modifier and Type Field Description (package private) static intDEFAULT_EXTENTThe default extent for a vector tileprivate static byteDEFAULT_VERSIONprivate intextentThe extent of the tile, typically 4096.private static byteEXTENT_FIELDprivate static byteFEATURE_FIELDprivate java.util.List<Feature>featureCollectionThe actual features of this layer in this tileprivate static byteKEY_FIELDprivate java.util.List<java.lang.String>keyListA list of unique keys.static byteLAYER_FIELDThe field value for a layer (inProtobufRecord.getField())private java.lang.StringnameA unique name for the layer.private static byteNAME_FIELDprivate static byteVALUE_FIELDprivate java.util.List<java.lang.Object>valueListA list of unique values.private byteversionThis is technically an integer, but there are currently only two major versions (1, 2).private static byteVERSION_FIELD
-
Constructor Summary
Constructors Constructor Description Layer(byte[] bytes)Create a new layerLayer(java.util.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 voiddestroy()Called when the object has been destroyed.booleanequals(java.lang.Object other)private static java.util.Collection<ProtobufRecord>getAllRecords(byte[] bytes)Get all the records from a array of bytesintgetExtent()Get the extent of the tilejava.util.Collection<Feature>getFeatures()Get the feature on this layerjava.util.Collection<Geometry>getGeometry()Get the geometry for this layerjava.lang.StringgetKey(int index)Get a specified keyjava.lang.StringgetName()Get the name of the layerjava.lang.ObjectgetValue(int index)Get a specified valuebytegetVersion()Get the Mapbox Vector Tile version specification for this layerinthashCode()private voidparseValueRecord(java.io.ByteArrayOutputStream byteArrayOutputStream, ProtobufRecord protobufRecord)
-
-
-
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 java.lang.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.
-
keyList
private final java.util.List<java.lang.String> keyList
A list of unique keys. Order is important. Optional.
-
valueList
private final java.util.List<java.lang.Object> valueList
A list of unique values. Order is important. Optional.
-
featureCollection
private final java.util.List<Feature> featureCollection
The actual features of this layer in this tile
-
-
Constructor Detail
-
Layer
public Layer(java.util.Collection<ProtobufRecord> records) throws java.io.IOException
Create a layer from a collection of records- Parameters:
records- The records to convert to a layer- Throws:
java.io.IOException- - if an IO error occurs
-
Layer
public Layer(byte[] bytes) throws java.io.IOException
Create a new layer- Parameters:
bytes- The bytes that the layer comes from- Throws:
java.io.IOException- - if an IO error occurs
-
-
Method Detail
-
parseValueRecord
private void parseValueRecord(java.io.ByteArrayOutputStream byteArrayOutputStream, ProtobufRecord protobufRecord) throws java.io.IOException
- Throws:
java.io.IOException
-
getAllRecords
private static java.util.Collection<ProtobufRecord> getAllRecords(byte[] bytes) throws java.io.IOException
Get all the records from a array of bytes- Parameters:
bytes- The byte information- Returns:
- All the protobuf records
- Throws:
java.io.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 java.util.Collection<Feature> getFeatures()
Get the feature on this layer- Returns:
- the features
-
getGeometry
public java.util.Collection<Geometry> getGeometry()
Get the geometry for this layer- Returns:
- The geometry
-
getKey
public java.lang.String getKey(int index)
Get a specified key- Parameters:
index- The index in the key list- Returns:
- The actual key
-
getName
public java.lang.String getName()
Get the name of the layer- Returns:
- The layer name
-
getValue
public java.lang.Object getValue(int index)
Get a specified value- Parameters:
index- The index in the value list- Returns:
- The actual value. This can be a
String,Boolean,Integer, orFloatvalue.
-
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:DestroyableCalled when the object has been destroyed.- Specified by:
destroyin interfaceDestroyable
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-