Package com.mapbox.geojson
Class MultiLineString
java.lang.Object
com.mapbox.geojson.MultiLineString
- All Implemented Interfaces:
CoordinateContainer<List<List<Point>>>,GeoJson,Geometry,Serializable
A multilinestring is an array of LineString coordinate arrays.
This adheres to the RFC 7946 internet standard when serialized into JSON. When deserialized, this class becomes an immutable object which should be initiated using its static factory methods.
When representing a LineString that crosses the antimeridian, interoperability is improved by modifying their geometry. Any geometry that crosses the antimeridian SHOULD be represented by cutting it in two such that neither part's representation crosses the antimeridian.
For example, a line extending from 45 degrees N, 170 degrees E across the antimeridian to 45 degrees N, 170 degrees W should be cut in two and represented as a MultiLineString.
A sample GeoJson MultiLineString's provided below (in it's serialized state).
{
"type": "MultiLineString",
"coordinates": [
[
[100.0, 0.0],
[101.0, 1.0]
],
[
[102.0, 2.0],
[103.0, 3.0]
]
]
}
Look over the LineString documentation to get more information about
formatting your list of linestring objects correctly.- Since:
- 1.0.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbbox()A Feature Collection might have a member namedbboxto include information on the coordinate range for it'sFeatures.Provides the list of list ofPoints that make up the MultiLineString geometry.booleanstatic MultiLineStringCreate a new instance of this class by passing in a formatted valid JSON String.static MultiLineStringfromLineString(LineString lineString) Create a new instance of this class by passing in a singleLineStringobject.static MultiLineStringfromLineString(LineString lineString, BoundingBox bbox) Create a new instance of this class by passing in a singleLineStringobject.static MultiLineStringfromLineStrings(List<LineString> lineStrings) Create a new instance of this class by defining a list ofLineStringobjects and passing that list in as a parameter in this method.static MultiLineStringfromLineStrings(List<LineString> lineStrings, BoundingBox bbox) Create a new instance of this class by defining a list ofLineStringobjects and passing that list in as a parameter in this method.static MultiLineStringfromLngLats(List<List<Point>> points) Create a new instance of this class by defining a list of a list ofPoints which follow the correct specifications described in the Point documentation.static MultiLineStringfromLngLats(List<List<Point>> points, BoundingBox bbox) Create a new instance of this class by defining a list of a list ofPoints which follow the correct specifications described in the Point documentation.inthashCode()Returns a list of LineStrings which are currently making up this MultiLineString.toJson()This takes the currently defined values found inside this instance and converts it to a GeoJson string.toString()type()This describes the TYPE of GeoJson geometry this object is, thus this will always returnMultiLineString.static com.google.gson.TypeAdapter<MultiLineString>typeAdapter(com.google.gson.Gson gson) Gson type adapter for parsing Gson to this class.
-
Method Details
-
fromJson
Create a new instance of this class by passing in a formatted valid JSON String. If you are creating a MultiLineString object from scratch it is better to use one of the other provided static factory methods such asfromLineStrings(List).- Parameters:
json- a formatted valid JSON string defining a GeoJson MultiLineString- Returns:
- a new instance of this class defined by the values passed inside this static factory method
- Since:
- 1.0.0
-
fromLineStrings
Create a new instance of this class by defining a list ofLineStringobjects and passing that list in as a parameter in this method. The LineStrings should comply with the GeoJson specifications described in the documentation.- Parameters:
lineStrings- a list of LineStrings which make up this MultiLineString- Returns:
- a new instance of this class defined by the values passed inside this static factory method
- Since:
- 3.0.0
-
fromLineStrings
public static MultiLineString fromLineStrings(@NonNull List<LineString> lineStrings, @Nullable BoundingBox bbox) Create a new instance of this class by defining a list ofLineStringobjects and passing that list in as a parameter in this method. The LineStrings should comply with the GeoJson specifications described in the documentation. Optionally, pass in an instance of aBoundingBoxwhich better describes this MultiLineString.- Parameters:
lineStrings- a list of LineStrings which make up this MultiLineStringbbox- optionally include a bbox definition- Returns:
- a new instance of this class defined by the values passed inside this static factory method
- Since:
- 3.0.0
-
fromLineString
Create a new instance of this class by passing in a singleLineStringobject. The LineStrings should comply with the GeoJson specifications described in the documentation.- Parameters:
lineString- a single LineString which make up this MultiLineString- Returns:
- a new instance of this class defined by the values passed inside this static factory method
- Since:
- 3.0.0
-
fromLineString
public static MultiLineString fromLineString(@NonNull LineString lineString, @Nullable BoundingBox bbox) Create a new instance of this class by passing in a singleLineStringobject. The LineStrings should comply with the GeoJson specifications described in the documentation.- Parameters:
lineString- a single LineString which make up this MultiLineStringbbox- optionally include a bbox definition- Returns:
- a new instance of this class defined by the values passed inside this static factory method
- Since:
- 3.0.0
-
fromLngLats
Create a new instance of this class by defining a list of a list ofPoints which follow the correct specifications described in the Point documentation. Note that there should not be any duplicate points inside the list and the points combined should create a LineString with a distance greater than 0.- Parameters:
points- a list ofPoints which make up the MultiLineString geometry- Returns:
- a new instance of this class defined by the values passed inside this static factory method
- Since:
- 3.0.0
-
fromLngLats
public static MultiLineString fromLngLats(@NonNull List<List<Point>> points, @Nullable BoundingBox bbox) Create a new instance of this class by defining a list of a list ofPoints which follow the correct specifications described in the Point documentation. Note that there should not be any duplicate points inside the list and the points combined should create a LineString with a distance greater than 0.- Parameters:
points- a list ofPoints which make up the MultiLineString geometrybbox- optionally include a bbox definition- Returns:
- a new instance of this class defined by the values passed inside this static factory method
- Since:
- 3.0.0
-
type
This describes the TYPE of GeoJson geometry this object is, thus this will always returnMultiLineString. -
bbox
A Feature Collection might have a member namedbboxto include information on the coordinate range for it'sFeatures. The value of the bbox member MUST be a list of size 2*n where n is the number of dimensions represented in the contained feature geometries, with all axes of the most southwesterly point followed by all axes of the more northeasterly point. The axes order of a bbox follows the axes order of geometries. -
coordinates
Provides the list of list ofPoints that make up the MultiLineString geometry.- Specified by:
coordinatesin interfaceCoordinateContainer<List<List<Point>>>- Returns:
- a list of points
- Since:
- 3.0.0
-
lineStrings
Returns a list of LineStrings which are currently making up this MultiLineString.- Returns:
- a list of
LineStrings - Since:
- 3.0.0
-
toJson
This takes the currently defined values found inside this instance and converts it to a GeoJson string. -
typeAdapter
Gson type adapter for parsing Gson to this class.- Parameters:
gson- the builtGsonobject- Returns:
- the TYPE adapter for this class
- Since:
- 3.0.0
-
toString
-
equals
-
hashCode
public int hashCode()
-