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

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

The newest version!
package com.backendless.persistence;

import java.util.Objects;


public class GeometryDTO
{
  private String geomClass;
  private Integer srsId;
  private String geoJson;

  public GeometryDTO()
  {
  }

  public GeometryDTO( String geomClass, Integer srsId, String geoJson )
  {
    this.geomClass = geomClass;
    this.srsId = srsId;
    this.geoJson = geoJson;
  }

  public String getGeomClass()
  {
    return geomClass;
  }

  public void setGeomClass( String geomClass )
  {
    this.geomClass = geomClass;
  }

  public Integer getSrsId()
  {
    return srsId;
  }

  public void setSrsId( Integer srsId )
  {
    this.srsId = srsId;
  }

  public String getGeoJson()
  {
    return geoJson;
  }

  public void setGeoJson( String geoJson )
  {
    this.geoJson = geoJson;
  }

  public  T toGeometry()
  {
    GeoJSONParser geoJSONParser = srsId != null ?
            new GeoJSONParser( SpatialReferenceSystemEnum.valueBySRSId( srsId ), geomClass ) :
            new GeoJSONParser( geomClass );
    @SuppressWarnings( "unchecked" )
    T result = (T) geoJSONParser.read( this.geoJson );
    return result;
  }

  @Override
  public boolean equals( Object o )
  {
    if( this == o )
      return true;
    if( !(o instanceof GeometryDTO) )
      return false;
    GeometryDTO that = (GeometryDTO) o;
    return Objects.equals( geomClass, that.geomClass ) && Objects.equals( srsId, that.srsId ) && Objects.equals( geoJson, that.geoJson );
  }

  @Override
  public int hashCode()
  {
    return Objects.hash( geomClass, srsId, geoJson );
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy