Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ST_GeometryFromShape #103

Closed
randallwhitman opened this issue Aug 11, 2016 · 3 comments
Closed

ST_GeometryFromShape #103

randallwhitman opened this issue Aug 11, 2016 · 3 comments
Milestone

Comments

@randallwhitman
Copy link
Contributor

randallwhitman commented Aug 11, 2016

ST_GeomFromShape in SQL-RDBMS
ST_AsShape for Hive

@randallwhitman
Copy link
Contributor Author

I found the following untracked file, never committed to git - probably did not pass testing:

package com.esri.hadoop.hive;

import java.nio.ByteBuffer;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.io.BytesWritable;

import com.esri.core.geometry.SpatialReference;
import com.esri.core.geometry.ogc.OGCGeometry;

public class ST_GeomFromShape extends ST_Geometry {

    static final Log LOG = LogFactory.getLog(ST_GeomFromShape.class.getName());

    public BytesWritable evaluate(BytesWritable shape) throws UDFArgumentException {
        return evaluate(shape, 0);
    }

    public BytesWritable evaluate(BytesWritable shape, int wkid) throws UDFArgumentException {

        //String wkt = shape.toString();
        LOG.error("geom-from-shape");  /// debug/todo
        try {
            SpatialReference spatialReference = null;
            if (wkid != GeometryUtils.WKID_UNKNOWN) {
                spatialReference = SpatialReference.create(wkid);
            }
            // byte [] byteArr = shape.getBytes();
            // ByteBuffer byteBuf = ByteBuffer.allocate(byteArr.length);
            // byteBuf.put(byteArr);
            // TODO: little-endian order: .order(ByteOrder.LITTLE_ENDIAN)
            OGCGeometry ogcObj = OGCGeometry.fromEsriShape(ByteBuffer.wrap(shape.getBytes()));
            ogcObj.setSpatialReference(spatialReference);
            return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj);
        } catch (Exception e) {
            LogUtils.Log_ExceptionThrown(LOG, "geom-from-shape", e);  //todo
            return null;
        }
    }

}

gisfromscratch added a commit to gisfromscratch/spatial-framework-for-hadoop that referenced this issue Aug 17, 2016
gisfromscratch added a commit to gisfromscratch/spatial-framework-for-hadoop that referenced this issue Aug 17, 2016
gisfromscratch added a commit to gisfromscratch/spatial-framework-for-hadoop that referenced this issue Aug 17, 2016
gisfromscratch added a commit to gisfromscratch/spatial-framework-for-hadoop that referenced this issue Aug 17, 2016
@randallwhitman randallwhitman added this to the v1.2 milestone Oct 27, 2016
@randallwhitman
Copy link
Contributor Author

Need to add to the documentation on wiki

@randallwhitman
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant