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

com.datastax.driver.dse.geometry.Point Maven / Gradle / Ivy

Go to download

A driver for DataStax Enterprise (DSE) and Apache Cassandra 1.2+ clusters that works exclusively with the Cassandra Query Language version 3 (CQL3) and Cassandra's binary protocol, supporting DSE-specific features such as geospatial types, DSE Graph and DSE authentication.

There is a newer version: 2.4.0
Show newest version
/*
 * Copyright DataStax, Inc.
 *
 * This software can be used solely with DataStax Enterprise. Please consult the license at
 * http://www.datastax.com/terms/datastax-dse-driver-license-terms
 */
package com.datastax.driver.dse.geometry;

import com.datastax.driver.core.exceptions.InvalidTypeException;
import com.esri.core.geometry.ogc.OGCPoint;
import java.nio.ByteBuffer;

/**
 * The driver-side representation of DSE's {@code PointType}.
 *
 * 

This is a zero-dimensional object that represents a specific (X,Y) location in a * two-dimensional XY-plane. In case of Geographic Coordinate Systems, the X coordinate is the * longitude and the Y is the latitude. */ public class Point extends Geometry { private static final long serialVersionUID = 6329957740309318716L; /** * Creates a point from its Well-known * Text (WKT) representation. * * @param source the Well-known Text representation to parse. * @return the point represented by the WKT. * @throws InvalidTypeException if the string does not contain a valid Well-known Text * representation. */ public static Point fromWellKnownText(String source) { return new Point(fromOgcWellKnownText(source, OGCPoint.class)); } /** * Creates a point from its Well-known Binary * (WKB) representation. * * @param source the Well-known Binary representation to parse. * @return the point represented by the WKB. * @throws InvalidTypeException if the provided {@link ByteBuffer} does not contain a valid * Well-known Binary representation. */ public static Point fromWellKnownBinary(ByteBuffer source) { return new Point(fromOgcWellKnownBinary(source, OGCPoint.class)); } /** * Creates a point from a GeoJSON * Point representation. * * @param source the GeoJSON Point * representation to parse. * @return the point represented by the GeoJSON Point. * @throws InvalidTypeException if the string does not contain a valid GeoJSON Point representation. */ public static Point fromGeoJson(String source) { return new Point(fromOgcGeoJson(source, OGCPoint.class)); } /** * Creates a new point. * * @param x the X coordinate (or its longitude in Geographic Coordinate Systems). * @param y the Y coordinate (or its latitude in Geographic Coordinate Systems). */ public Point(double x, double y) { this(new OGCPoint(new com.esri.core.geometry.Point(x, y), Geometry.SPATIAL_REFERENCE_4326)); } Point(OGCPoint point) { super(point); } @Override OGCPoint getOgcGeometry() { return (OGCPoint) super.getOgcGeometry(); } /** * Returns the X coordinate of this 2D point (or its longitude in Geographic Coordinate Systems. * * @return the X coordinate. */ public double X() { return getOgcGeometry().X(); } /** * Returns the Y coordinate of this 2D point (or its latitude in Geographic Coordinate Systems). * * @return the Y coordinate. */ public double Y() { return getOgcGeometry().Y(); } /** * This object gets replaced by an internal proxy for serialization. * * @serialData a single byte array containing the Well-Known Binary representation. */ private Object writeReplace() { return new WkbSerializationProxy(this.asWellKnownBinary()); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy