[
https://issues.apache.org/jira/browse/TINKERPOP-2558?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18141610#comment-18141610
]
ASF GitHub Bot commented on TINKERPOP-2558:
-------------------------------------------
GumpacG commented on code in PR #3754:
URL: https://github.com/apache/tinkerpop/pull/3754#discussion_r4519632520
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/geo/CoordinateValidator.java:
##########
@@ -0,0 +1,205 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.tinkerpop.gremlin.structure.geo;
+
+import java.util.List;
+
+/**
+ * Package-private helper for coordinate validation.
+ */
+final class CoordinateValidator {
+
+ static final int SRID_CARTESIAN = 0;
+ static final int SRID_GEOGRAPHIC = 4326;
+ static final int MAX_NESTING_DEPTH = 32;
+
+ private CoordinateValidator() {
+ }
+
+ /**
+ * Returns the Model for a given SRID.
+ */
+ static Model modelForSrid(final int srid) {
+ if (srid == SRID_CARTESIAN) {
+ return Model.CARTESIAN;
+ } else if (srid == SRID_GEOGRAPHIC) {
+ return Model.GEOGRAPHIC;
+ } else {
+ return Model.OTHER;
+ }
+ }
+
+ /**
+ * Returns the SRID for a given Model.
+ */
+ static int sridForModel(final Model model) {
+ if (model == null) {
+ throw new IllegalArgumentException("Model cannot be null");
+ }
+ switch (model) {
+ case CARTESIAN:
+ return SRID_CARTESIAN;
+ case GEOGRAPHIC:
+ return SRID_GEOGRAPHIC;
+ default:
+ throw new IllegalArgumentException("Model.OTHER cannot be used
in constructors; use fromWkt(wkt, srid) or fromWkb(wkb, srid) with an explicit
SRID");
+ }
+ }
+
+ /**
+ * Validates x coordinate (longitude for GEOGRAPHIC).
+ */
+ static void validateX(final double x, final int srid) {
+ if (Double.isNaN(x) || Double.isInfinite(x)) {
+ throw new IllegalArgumentException("x coordinate cannot be NaN or
infinite");
+ }
+ if (srid == SRID_GEOGRAPHIC) {
+ if (x < -180.0 || x > 180.0) {
+ throw new IllegalArgumentException("GEOGRAPHIC longitude must
be in [-180, 180], got: " + x);
+ }
+ }
+ }
+
+ /**
+ * Validates y coordinate (latitude for GEOGRAPHIC).
+ */
+ static void validateY(final double y, final int srid) {
+ if (Double.isNaN(y) || Double.isInfinite(y)) {
+ throw new IllegalArgumentException("y coordinate cannot be NaN or
infinite");
+ }
+ if (srid == SRID_GEOGRAPHIC) {
+ if (y < -90.0 || y > 90.0) {
+ throw new IllegalArgumentException("GEOGRAPHIC latitude must
be in [-90, 90], got: " + y);
+ }
+ }
+ }
+
+ /**
+ * Validates z coordinate.
+ */
+ static void validateZ(final double z) {
+ if (Double.isNaN(z)) {
+ throw new IllegalArgumentException("z coordinate cannot be NaN
when provided; use 2D constructor for 2D points");
+ }
+ if (Double.isInfinite(z)) {
+ throw new IllegalArgumentException("z coordinate cannot be
infinite");
+ }
+ }
+
+ /**
+ * Validates that the nesting depth does not exceed the maximum.
+ */
+ static void validateNestingDepth(final int depth) {
Review Comment:
Added cases for argument errors in the docs
> GEO Spatial APIs
> ----------------
>
> Key: TINKERPOP-2558
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2558
> Project: TinkerPop
> Issue Type: Improvement
> Components: process
> Affects Versions: 3.5.0
> Reporter: Jitesh
> Priority: Major
>
> Provide support for Geo based APIs (predicates, objects, etc)
>
>
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)