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

com.datastax.dse.driver.api.core.data.geometry.Point Maven / Gradle / Ivy

The newest version!
/*
 * Copyright DataStax, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.datastax.dse.driver.api.core.data.geometry;

import com.datastax.dse.driver.internal.core.data.geometry.DefaultGeometry;
import com.datastax.dse.driver.internal.core.data.geometry.DefaultPoint;
import com.esri.core.geometry.ogc.OGCPoint;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.nio.ByteBuffer;

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

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. * *

The default implementation returned by the driver is immutable. */ public interface Point extends Geometry { /** * 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 IllegalArgumentException if the string does not contain a valid Well-known Text * representation. */ @NonNull static Point fromWellKnownText(@NonNull String source) { return new DefaultPoint(DefaultGeometry.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 IllegalArgumentException if the provided {@link ByteBuffer} does not contain a valid * Well-known Binary representation. */ @NonNull static Point fromWellKnownBinary(@NonNull ByteBuffer source) { return new DefaultPoint(DefaultGeometry.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 IllegalArgumentException if the string does not contain a valid GeoJSON Point representation. */ @NonNull static Point fromGeoJson(@NonNull String source) { return new DefaultPoint(DefaultGeometry.fromOgcGeoJson(source, OGCPoint.class)); } /** * Creates a new point. * * @param x The X coordinate of this point (or its longitude in Geographic Coordinate Systems). * @param y The Y coordinate of this point (or its latitude in Geographic Coordinate Systems). * @return the point represented by coordinates. */ @NonNull static Point fromCoordinates(double x, double y) { return new DefaultPoint(x, y); } /** * Returns the X coordinate of this 2D point (or its longitude in Geographic Coordinate Systems). */ double X(); /** * Returns the Y coordinate of this 2D point (or its latitude in Geographic Coordinate Systems). */ double Y(); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy