All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.backendless.persistence.Point Maven / Gradle / Ivy

The newest version!
package com.backendless.persistence;

import java.util.Objects;


public class Point extends Geometry
{
  public static final double PRECISION = .000000001;
  public static final String GEOJSON_TYPE = "Point";
  public static final String WKT_TYPE = GEOJSON_TYPE.toUpperCase();

  private double x;
  private double y;


  public Point()
  {
    super( SpatialReferenceSystemEnum.DEFAULT );
  }

  public Point( SpatialReferenceSystemEnum srs )
  {
    super( srs );
  }

  public double getX()
  {
    return x;
  }

  public double getY()
  {
    return y;
  }

  public double getLongitude()
  {
    return x;
  }

  public double getLatitude()
  {
    return y;
  }

  public Point setX( double x )
  {
    this.x = x;
    return this;
  }

  public Point setY( double y )
  {
    this.y = y;
    return this;
  }

  public Point setLongitude( double x )
  {
    return setX( x );
  }

  public Point setLatitude( double y )
  {
    return setY( y );
  }

  @Override
  public String getGeojsonType()
  {
    return Point.GEOJSON_TYPE;
  }

  @Override
  public String getWktType()
  {
    return Point.WKT_TYPE;
  }

  @Override
  String wktCoordinatePairs()
  {
    return x + " " + y;
  }

  @Override
  String jsonCoordinatePairs()
  {
    return "[" + x + "," + y + "]";
  }

  @Override
  public boolean equals( Object o )
  {
    if( this == o )
      return true;
    if( !(o instanceof Point) )
      return false;
    Point point = (Point) o;
    return Math.abs( point.x - x ) < PRECISION && Math.abs( point.y - y ) < PRECISION && srs == point.srs;
  }

  @Override
  public int hashCode()
  {
    return Objects.hash( x, y, srs );
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy