Change-Id: Ic89f4669529ac13f3c69ede8553cf57bbfd73760 Former-commit-id: 48c392d8000d8cc3a5c8371319fddd776566ef32
56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
# #
|
|
# This software was developed and / or modified by Raytheon Company,
|
|
# pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
|
#
|
|
# U.S. EXPORT CONTROLLED TECHNICAL DATA
|
|
# This software product contains export-restricted data whose
|
|
# export/transfer/disclosure is restricted by U.S. law. Dissemination
|
|
# to non-U.S. persons whether in the United States or abroad requires
|
|
# an export license or other authorization.
|
|
#
|
|
# Contractor Name: Raytheon Company
|
|
# Contractor Address: 6825 Pine Street, Suite 340
|
|
# Mail Stop B8
|
|
# Omaha, NE 68106
|
|
# 402.291.0100
|
|
#
|
|
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
|
# further licensing information.
|
|
# #
|
|
|
|
|
|
from com.vividsolutions.jts.io import WKTReader
|
|
from com.vividsolutions.jts.geom import Geometry
|
|
from shapely.geometry.base import BaseGeometry
|
|
from shapely import wkt
|
|
|
|
from com.raytheon.uf.common.python import PyJavaUtil
|
|
|
|
#
|
|
# Handler for geometries from Python to Java and back.
|
|
#
|
|
#
|
|
#
|
|
# SOFTWARE HISTORY
|
|
#
|
|
# Date Ticket# Engineer Description
|
|
# ------------ ---------- ----------- --------------------------
|
|
# 10/14/13 2250 mnash Initial creation of JUtil handler
|
|
#
|
|
#
|
|
|
|
def shapelyToJTS(val):
|
|
valtype = type(val)
|
|
if issubclass(valtype, BaseGeometry):
|
|
reader = WKTReader()
|
|
retObj = reader.read(val.to_wkt())
|
|
return True, retObj
|
|
return False, val
|
|
|
|
def jtsToShapely(obj, customConverter=None):
|
|
if PyJavaUtil.isSubclass(obj, Geometry):
|
|
return True, _toShapely(obj)
|
|
return False, obj
|
|
|
|
def _toShapely(obj):
|
|
return wkt.loads(obj.toText())
|