com.backendless.persistence.LineString Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons Show documentation
Show all versions of commons Show documentation
Commons lib for both server and client Java/Android SDKs
The newest version!
package com.backendless.persistence;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class LineString extends Geometry
{
public static final String GEOJSON_TYPE = "LineString";
public static final String WKT_TYPE = GEOJSON_TYPE.toUpperCase();
private final ArrayList points;
public LineString( List points )
{
this( points, SpatialReferenceSystemEnum.DEFAULT );
}
public LineString( List points, SpatialReferenceSystemEnum srs )
{
super( srs );
this.points = new ArrayList<>( points );
}
public List getPoints()
{
return (List) this.points.clone();
}
public LineString setPoints( List points )
{
this.points.clear();
this.points.addAll( points );
return this;
}
@Override
public String getGeojsonType()
{
return LineString.GEOJSON_TYPE;
}
@Override
public String getWktType()
{
return LineString.WKT_TYPE;
}
@Override
String jsonCoordinatePairs()
{
StringBuilder sb = new StringBuilder();
sb.append( '[' );
for( Point p : this.getPoints() )
sb.append( p.jsonCoordinatePairs() ).append( ',' );
sb.setCharAt( sb.length() - 1, ']' );
return sb.toString();
}
@Override
String wktCoordinatePairs()
{
StringBuilder sb = new StringBuilder();
for( Point p : this.getPoints() )
sb.append( p.wktCoordinatePairs() ).append( ',' );
sb.deleteCharAt( sb.length() - 1 );
return sb.toString();
}
@Override
public boolean equals( Object o )
{
if( this == o )
return true;
if( !(o instanceof LineString) )
return false;
LineString that = (LineString) o;
return Objects.equals( points, that.points ) && srs == that.srs;
}
@Override
public int hashCode()
{
return Objects.hash( points, srs );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy