[Liblas-commits] r1055 - in trunk: include/liblas/capi
python/liblas python/tests src
liblas-commits at liblas.org
liblas-commits at liblas.org
Fri Feb 20 00:43:41 EST 2009
Author: hobu
Date: Fri Feb 20 00:43:41 2009
New Revision: 1055
URL: http://liblas.org/changeset/1055
Log:
start on Python API for SRS
Added:
trunk/python/liblas/srs.py (contents, props changed)
trunk/python/tests/SRS.txt (contents, props changed)
Modified:
trunk/include/liblas/capi/liblas.h
trunk/python/liblas/__init__.py
trunk/python/liblas/core.py
trunk/python/liblas/header.py
trunk/python/tests/Header.txt
trunk/src/las_c_api.cpp
Modified: trunk/include/liblas/capi/liblas.h
==============================================================================
--- trunk/include/liblas/capi/liblas.h (original)
+++ trunk/include/liblas/capi/liblas.h Fri Feb 20 00:43:41 2009
@@ -1081,7 +1081,8 @@
LAS_DLL LASError LASSRS_SetWKT(LASSRSH hSRS, const char* value);
LAS_DLL char* LASSRS_GetProj4(LASSRSH hSRS);
LAS_DLL LASError LASSRS_SetProj4(LASSRSH hSRS, const char* value);
-
+LAS_DLL LASSRSH LASHeader_GetSRS(const LASHeaderH hHeader);
+LAS_DLL LASError LASHeader_SetSRS(LASHeaderH hHeader, const LASSRSH hSRS);
LAS_C_END
#endif
Modified: trunk/python/liblas/__init__.py
==============================================================================
--- trunk/python/liblas/__init__.py (original)
+++ trunk/python/liblas/__init__.py Fri Feb 20 00:43:41 2009
@@ -1,6 +1,8 @@
from core import *
-version = core.get_version()
+version = get_version()
import file
import point
import header
-import vlr
\ No newline at end of file
+import vlr
+import color
+import srs
Modified: trunk/python/liblas/core.py
==============================================================================
--- trunk/python/liblas/core.py (original)
+++ trunk/python/liblas/core.py Fri Feb 20 00:43:41 2009
@@ -563,4 +563,35 @@
las.LASPoint_GetColor.restype = ctypes.c_void_p
las.LASPoint_SetColor.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
-las.LASPoint_SetColor.errcheck = check_return
\ No newline at end of file
+las.LASPoint_SetColor.errcheck = check_return
+
+
+
+las.LASSRS_Create.errcheck = check_void
+las.LASSRS_Create.restype = ctypes.c_void_p
+
+las.LASSRS_Destroy.argtypes = [ctypes.c_void_p]
+las.LASSRS_Destroy.errcheck = check_void_done
+
+las.LASSRS_GetProj4.argtypes = [ctypes.c_void_p]
+las.LASSRS_GetProj4.errcheck = check_value_free
+las.LASSRS_SetProj4.restype = ctypes.c_int
+las.LASSRS_SetProj4.argtypes = [ctypes.c_void_p, ctypes.c_char_p]
+las.LASSRS_SetProj4.errcheck = check_return
+
+las.LASSRS_GetWKT.argtypes = [ctypes.c_void_p]
+las.LASSRS_GetWKT.errcheck = check_value_free
+las.LASSRS_SetWKT.restype = ctypes.c_int
+las.LASSRS_SetWKT.argtypes = [ctypes.c_void_p, ctypes.c_char_p]
+las.LASSRS_SetWKT.errcheck = check_return
+
+las.LASSRS_AddVLR.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
+las.LASSRS_AddVLR.errcheck = check_value
+las.LASSRS_AddVLR.restype = ctypes.c_int
+
+las.LASHeader_GetSRS.argtypes = [ctypes.c_void_p]
+las.LASHeader_GetSRS.errcheck = check_void
+las.LASHeader_GetSRS.restype = ctypes.c_void_p
+
+las.LASHeader_SetSRS.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
+las.LASHeader_SetSRS.errcheck = check_return
Modified: trunk/python/liblas/header.py
==============================================================================
--- trunk/python/liblas/header.py (original)
+++ trunk/python/liblas/header.py Fri Feb 20 00:43:41 2009
@@ -44,6 +44,7 @@
import datetime
import guid
import vlr
+import srs
def leap_year(year):
if (year % 400) == 0:
@@ -371,3 +372,8 @@
def DeleteVLR(self, value):
core.las.LASHeader_DeleteVLR(self.handle, value)
+ def get_srs(self):
+ return srs.SRS(handle=core.las.LASHeader_GetSRS(self.handle))
+ def set_srs(self, value):
+ return core.las.LASHeader_SetSRS(self.handle, self.value)
+ srs = property(get_srs, set_srs)
\ No newline at end of file
Added: trunk/python/liblas/srs.py
==============================================================================
--- (empty file)
+++ trunk/python/liblas/srs.py Fri Feb 20 00:43:41 2009
@@ -0,0 +1,91 @@
+"""
+/******************************************************************************
+ * $Id$
+ *
+ * Project: libLAS - http://liblas.org - A BSD library for LAS format data.
+ * Purpose: Python SRS implementation
+ * Author: Howard Butler, hobu.inc at gmail.com
+ *
+ ******************************************************************************
+ * Copyright (c) 2009, Howard Butler
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of the Martin Isenburg or Iowa Department
+ * of Natural Resources nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ ****************************************************************************/
+ """
+import core
+import ctypes
+import vlr
+
+class SRS(object):
+ def __init__(self, owned=True, handle=None):
+ if handle:
+ self.handle = handle
+ else:
+ self.handle = core.las.LASSRS_Create()
+ self.owned = owned
+ def __del__(self):
+ if self.owned:
+ if self.handle and core:
+ core.las.LASSRS_Destroy(self.handle)
+
+ def get_wkt(self):
+ return core.las.LASSRS_GetWKT(self.handle)
+ def set_wkt(self, value):
+ return core.las.LASSRS_SetWKT(self.handle, value)
+ wkt = property(get_wkt, set_wkt)
+
+ def get_proj4(self):
+ return core.las.LASSRS_GetProj4(self.handle)
+ def set_proj4(self, value):
+ return core.las.LASSRS_SetProj4(self.handle, value)
+ proj4 = property(get_proj4, set_proj4)
+
+ def add_vlr(self, vlr):
+ return core.las.LASSRS_AddVLR(self.handle, vlr.handle)
+
+ # def get_red(self):
+ # return core.las.LASColor_GetRed(self.handle)
+ # def set_red(self, value):
+ # return core.las.LASColor_SetRed(self.handle, value)
+ # red = property(get_red, set_red)
+ #
+ # def get_green(self):
+ # return core.las.LASColor_GetGreen(self.handle)
+ # def set_green(self, value):
+ # return core.las.LASColor_SetGreen(self.handle, value)
+ # green = property(get_green, set_green)
+ #
+ # def get_blue(self):
+ # return core.las.LASColor_GetBlue(self.handle)
+ # def set_blue(self, value):
+ # return core.las.LASColor_SetBlue(self.handle, value)
+ # blue = property(get_blue, set_blue)
+
Modified: trunk/python/tests/Header.txt
==============================================================================
--- trunk/python/tests/Header.txt (original)
+++ trunk/python/tests/Header.txt Fri Feb 20 00:43:41 2009
@@ -38,7 +38,7 @@
datetime.datetime(2008, 3, 19, 0, 0)
>>> h.software_id
- 'libLAS 1.0'
+ 'libLAS 1.2'
>>> h.software_id = 'hobu'
>>> h.software_id
'hobu'
@@ -92,4 +92,8 @@
''
>>> h.proj4 = '+proj=utm +zone=17 +ellps=WGS84 +units=m'
>>> h.proj4
- '+proj=utm +zone=17 +ellps=WGS84 +units=m'
\ No newline at end of file
+ '+proj=utm +zone=17 +ellps=WGS84 +units=m'
+
+ >>> s = h.srs
+ >>> s.proj4
+ '+to_meter=1.0000000000'
\ No newline at end of file
Added: trunk/python/tests/SRS.txt
==============================================================================
--- (empty file)
+++ trunk/python/tests/SRS.txt Fri Feb 20 00:43:41 2009
@@ -0,0 +1,4 @@
+ >>> from liblas import srs
+ >>> s = srs.SRS()
+ >>> s.proj4
+ ''
\ No newline at end of file
Modified: trunk/src/las_c_api.cpp
==============================================================================
--- trunk/src/las_c_api.cpp (original)
+++ trunk/src/las_c_api.cpp Fri Feb 20 00:43:41 2009
@@ -1780,6 +1780,31 @@
return LE_None;
}
+LAS_DLL LASErrorEnum LASHeader_SetSRS(LASHeaderH hHeader, const LASSRSH hSRS) {
+
+ VALIDATE_POINTER1(hHeader, "LASHeader_SetSRS", LE_Failure);
+ VALIDATE_POINTER1(hSRS, "LASHeader_SetSRS", LE_Failure);
+
+ try {
+ ((LASHeader*) hHeader)->SetSRS(*((LASSRS*)hSRS));
+ }
+ catch (std::exception const& e) {
+ LASError_PushError(LE_Failure, e.what(), "LASHeader_SetSRS");
+ return LE_Failure;
+ }
+
+
+ return LE_None;
+}
+
+LAS_DLL LASSRSH LASHeader_GetSRS(const LASHeaderH hHeader) {
+ VALIDATE_POINTER1(hHeader, "LASHeader_GetSRS", 0);
+
+ LASSRS srs = ((LASHeader*) hHeader)->GetSRS();
+ return (LASSRSH) new LASSRS(srs);
+}
+
+
LAS_C_END
#ifdef _MSC_VER
More information about the Liblas-commits
mailing list