ayushtkn commented on code in PR #6581:
URL: https://github.com/apache/hive/pull/6581#discussion_r3633982272


##########
ql/src/java/org/apache/hadoop/hive/ql/udf/esri/GeometryUtils.java:
##########
@@ -17,29 +17,236 @@
  */
 package org.apache.hadoop.hive.ql.udf.esri;
 
-import com.esri.core.geometry.Geometry;
-import com.esri.core.geometry.GeometryEngine;
-import com.esri.core.geometry.MapGeometry;
-import com.esri.core.geometry.OperatorImportFromESRIShape;
-import com.esri.core.geometry.Polygon;
-import com.esri.core.geometry.SpatialReference;
-import com.esri.core.geometry.ogc.OGCGeometry;
 import com.google.common.cache.Cache;
 import com.google.common.cache.CacheBuilder;
 import 
org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
 import 
org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableBinaryObjectInspector;
 import org.apache.hadoop.io.BytesWritable;
+import org.locationtech.jts.algorithm.Orientation;
+import org.locationtech.jts.geom.CoordinateSequence;
+import org.locationtech.jts.geom.Geometry;
+import org.locationtech.jts.geom.GeometryCollection;
+import org.locationtech.jts.geom.GeometryFactory;
+import org.locationtech.jts.geom.LineString;
+import org.locationtech.jts.geom.LinearRing;
+import org.locationtech.jts.geom.MultiPolygon;
+import org.locationtech.jts.geom.Point;
+import org.locationtech.jts.geom.Polygon;
+import org.locationtech.jts.io.Ordinate;
+import org.locationtech.jts.io.ParseException;
+import org.locationtech.jts.io.WKBReader;
+import org.locationtech.jts.io.WKBWriter;
+import org.locationtech.jts.io.WKTReader;
+import org.locationtech.jts.io.WKTWriter;
+import org.locationtech.jts.io.geojson.GeoJsonReader;
+import org.locationtech.jts.io.geojson.GeoJsonWriter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
+import java.util.Arrays;
+import java.util.Set;
 
 public class GeometryUtils {
 
+  private static final Logger LOG = 
LoggerFactory.getLogger(GeometryUtils.class);
+
   private static final int SIZE_WKID = 4;
   private static final int SIZE_TYPE = 1;
 
   public static final int WKID_UNKNOWN = 0;
 
+  // Magic byte at offset 4 to distinguish new WKB format from old ESRI format.

Review Comment:
   Why accept both formats -> backward compatibility? Yes. The geometry 
transport value is a binary type, so geometry bytes written by the previous 
ESRI-library implementation can already be sitting in tables.
   Those legacy bytes use the old framing  WKID (little-endian, 4 bytes) + OGC 
type tag (1 byte, 0–6) + ESRI-shape payload  and must stay readable. New writes 
use the new framing  SRID (4 bytes) + 0xFF magic + WKB payload. The reader 
disambiguates on byte 4: a value of 0xFF (outside the old 0–6 type range) means 
new format, anything else means old. So it's read-both, write-new for the 
internal transport framing; the old framing is never written anymore.
   
   One correction to avoid confusion: the ESRI shape encoding itself is not 
retired ST_AsShape still writes it and ST_GeomFromShape reads it, as standalone 
serializations, exactly the way ST_AsBinary/ST_GeomFromWKB handle WKB. What's 
read-only is only the legacy transport prefix, not the shape format.
   
   > Is the shape path XY/XYZ only, with M dropped, while WKB keeps M? 
   
   Correct. `EsriShapeConverter` handles only the `XY` and `XYZ` shape types 
(1/3/5/8 and 11/13/15/18)  on both read and write  and not the measured 
variants (21/23/25/28), so M is dropped symmetrically on that path. The WKB 
path uses a dimension-aware writer and preserves all of XY / XYZ / XYM / XYZM. 
Hence M round-trips only through WKB (`ST_AsBinary`/`ST_GeomFromWKB`) and the 
new transport framing, never through the ESRI-shape path. If measured-shape 
support matters, adding those four shape types would be a reasonable follow-up.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to