Changeset: 90076d6d9007 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=90076d6d9007
Added Files:
        sql/backends/monet5/vaults/75_lidar.mal
        sql/backends/monet5/vaults/75_lidar.sql
        sql/backends/monet5/vaults/lidar.c
        sql/backends/monet5/vaults/lidar.h
        sql/backends/monet5/vaults/lidar.mal
Modified Files:
        configure.ag
        sql/backends/monet5/vaults/Makefile.ag
Branch: default
Log Message:

added the lidar vault


diffs (truncated from 1600 to 300 lines):

diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -163,6 +163,13 @@ AC_ARG_ENABLE(netcdf,
        enable_netcdf=$enableval,
        enable_netcdf=$dft_netcdf)
 
+dft_lidar=auto
+AC_ARG_ENABLE(lidar,
+       AS_HELP_STRING([--enable-lidar],
+               [enable support for LiDAR data (default=auto)]),
+       enable_lidar=$enableval,
+       enable_lidar=$dft_lidar)
+
 dft_sql=yes
 AC_ARG_ENABLE(sql,
        AS_HELP_STRING([--enable-sql],
@@ -2504,6 +2511,86 @@ if test "x$enable_netcdf" != xno; then
 fi
 AM_CONDITIONAL(HAVE_NETCDF, test x"$have_netcdf" != xno)
 
+# liblas, only used in lidar module
+org_have_liblas=auto
+have_liblas=$org_have_liblas
+LIBLAS_INCS=''
+LIBLAS_LIBS=''
+AC_ARG_WITH(liblas,
+       AS_HELP_STRING([--with-liblas=DIR],
+               [liblas library is installed in DIR]),
+       have_liblas="$withval")
+case "$enable_lidar" in
+yes|auto)
+       # liblas >= 1.8.0 required
+       LIBLAS_VERSION_REQUIRED_MIN=1.8.0
+       LIBLAS_CONFIG=''
+       # locate liblas-config
+       if test "x$have_liblas" != xno; then
+               case "$have_liblas" in
+               yes|auto)
+                       XPATH="$PATH"
+                       ;;
+               *)
+                       XPATH="$have_liblas/bin"
+                       have_liblas=yes
+                       ;;
+               esac
+               AC_PATH_PROG(LIBLAS_CONFIG,liblas-config,,$XPATH)
+               if test "x$LIBLAS_CONFIG" = x; then
+                       if test "x$have_liblas" = "xyes" ; then
+                               AC_MSG_ERROR([liblas-config not found in 
$XPATH])
+                       else
+                               have_liblas=no
+                               why_have_liblas="(liblas-config not found)"
+                       fi
+               fi
+       fi
+       # check the version if liblas
+       if test "x$have_liblas" != xno; then
+               AC_MSG_CHECKING([for liblas >= $LIBLAS_VERSION_REQUIRED_MIN])
+               LIBLAS_VERSION="`$LIBLAS_CONFIG --version`"
+               AC_MSG_RESULT(found $LIBLAS_VERSION)
+               if test MONETDB_VERSION_TO_NUMBER(echo $LIBLAS_VERSION) -lt 
MONETDB_VERSION_TO_NUMBER(echo $LIBLAS_VERSION_REQUIRED_MIN); then
+                       if test "x$have_liblas" = "xyes" ; then
+                               AC_MSG_ERROR([liblas version $LIBLAS_VERSION is 
too old])
+                       else
+                               have_liblas=no
+                               why_have_liblas="(liblas version 
$LIBLAS_VERSION is older than required version $LIBLAS_VERSION_REQUIRED_MIN)"
+                       fi
+               fi
+       fi
+       # read include dirs, libs and cflags
+       if test "x$have_liblas" != xno; then
+               LIBLAS_INCS="`$LIBLAS_CONFIG --includes`" 
+               LIBLAS_LIBS="`$LIBLAS_CONFIG --libs`"
+       fi
+       # if lidar is enabled and liblas was not found abort
+       if test "x$have_liblas" = xno; then
+               if test "x$enable_lidar" = xyes; then
+                       AC_MSG_ERROR([liblas library required for lidar module])
+               fi
+               # no liblas, so don't compile lidar
+               enable_lidar=no
+               if test "x$disable_lidar" = x; then
+                       disable_lidar=${why_have_liblas:-"(liblas library 
required for lidar module)"}
+               fi
+       fi
+       ;;
+no)
+       enable_lidar=no
+       have_liblas=no
+       why_have_liblas="(lidar module is disabled)"
+       ;;
+esac
+AC_SUBST(LIBLAS_INCS)
+AC_SUBST(LIBLAS_LIBS)
+AC_MSG_CHECKING(['enable lidar: $enable_lidar'])
+
+AM_CONDITIONAL(HAVE_LIDAR, test "x$enable_lidar" = xyes -o "x$enable_lidar" = 
xauto)
+
+AC_MSG_CHECKING(['enable lidar: $enable_lidar'])
+
 
 PKG_CHECK_MODULES([atomic_ops], [atomic_ops], [have_atomic_ops="yes"],
        [have_atomic_ops="no"; why_have_atomic_ops="(atomic_ops library not 
found)"])
@@ -3296,6 +3383,7 @@ for comp in \
        'gsl         ' \
        'fits        ' \
        'netcdf      ' \
+       'lidar       ' \
        'microhttpd  ' \
        'rintegration' \
        'odbc        ' \
@@ -3329,6 +3417,7 @@ for comp in \
        'java         ' \
        'java_control ' \
        'java_jdbc    ' \
+       'liblas       ' \
        'libxml2      ' \
        'openssl      ' \
        'pcre         ' \
diff --git a/sql/backends/monet5/vaults/75_lidar.mal 
b/sql/backends/monet5/vaults/75_lidar.mal
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/vaults/75_lidar.mal
@@ -0,0 +1,20 @@
+# The contents of this file are subject to the MonetDB Public License
+# Version 1.1 (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.monetdb.org/Legal/MonetDBLicense
+#
+# Software distributed under the License is distributed on an "AS IS"
+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+# License for the specific language governing rights and limitations
+# under the License.
+#
+# The Original Code is the MonetDB Database System.
+#
+# The Initial Developer of the Original Code is CWI.
+# Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+# Copyright August 2008-2015 MonetDB B.V.
+# All Rights Reserved.
+
+# This loads the MonetDB/SQL module
+library lidar;
+include lidar;
diff --git a/sql/backends/monet5/vaults/75_lidar.sql 
b/sql/backends/monet5/vaults/75_lidar.sql
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/vaults/75_lidar.sql
@@ -0,0 +1,2 @@
+create procedure lidarattach(fname string) external name lidar.attach;
+create procedure lidarload(tname string) external name lidar.load;
diff --git a/sql/backends/monet5/vaults/Makefile.ag 
b/sql/backends/monet5/vaults/Makefile.ag
--- a/sql/backends/monet5/vaults/Makefile.ag
+++ b/sql/backends/monet5/vaults/Makefile.ag
@@ -19,7 +19,8 @@ INCLUDES = ../../../include \
           ../../../../common/stream \
           ../../../../common/utils \
           ../../../../gdk \
-          $(READLINE_INCS) $(cfitsio_CFLAGS) $(curl_CFLAGS) $(netcdf_CFLAGS)
+          $(READLINE_INCS) $(cfitsio_CFLAGS) $(curl_CFLAGS) $(netcdf_CFLAGS) \
+          $(LIBLAS_INCS)
 
 lib__vault = {
        MODULE
@@ -107,7 +108,38 @@ headers_netcdfautoload = {
        SOURCES = 74_netcdf.mal
 }
 
+lib__lidar = {
+       MODULE
+       COND = HAVE_LIDAR
+       DIR = libdir/monetdb5
+       SOURCES = lidar.c
+       LIBS = ../../../../monetdb5/tools/libmonetdb5 \
+              $(LIBLAS_LIBS)
+}
+
+headers_lidarmal = {
+       COND = HAVE_LIDAR
+       HEADERS = mal
+       DIR = libdir/monetdb5
+       SOURCES = lidar.mal
+}
+
+headers_lidarsql = {
+       COND = HAVE_LIDAR
+       HEADERS = sql
+       DIR = libdir/monetdb5/createdb
+       SOURCES = 75_lidar.sql
+}
+
+headers_lidarautoload = {
+       COND = HAVE_LIDAR
+       HEADERS = mal
+       DIR = libdir/monetdb5/autoload
+       SOURCES = 75_lidar.mal
+}
+
 EXTRA_DIST_DIR = Tests
 EXTRA_DIST = 70_vault.mal vault.mal vault.sql vault.h \
             72_fits.mal fits.mal 72_fits.sql fits.h \
-            74_netcdf.mal netcdf.mal 74_netcdf.sql netcdf_vault.h 
+            74_netcdf.mal netcdf.mal 74_netcdf.sql netcdf_vault.h \
+            75_lidar.mal  lidar.mal  75_lidar.sql  lidar.h
diff --git a/sql/backends/monet5/vaults/lidar.c 
b/sql/backends/monet5/vaults/lidar.c
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/vaults/lidar.c
@@ -0,0 +1,1312 @@
+/*
+ * The contents of this file are subject to the MonetDB Public License
+ * Version 1.1 (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.monetdb.org/Legal/MonetDBLicense
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the MonetDB Database System.
+ *
+ * The Initial Developer of the Original Code is CWI.
+ * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+ * Copyright August 2008-2015 MonetDB B.V.
+ * All Rights Reserved.
+ */
+
+/*
+ * Author: K. Kyzirakos
+ *
+ * This module contains primitives for accessing data in LiDAR file format.
+ */
+
+#include <monetdb_config.h>
+#include <glob.h>
+
+/* clash with GDK? */
+// #undef htype
+// #undef ttype
+
+#include <liblas/capi/liblas.h>
+#include <liblas/capi/las_version.h>
+#include <liblas/capi/las_config.h>
+
+#include <lidar.h>
+#include <mutils.h>
+#include <sql_mvc.h>
+#include <sql_scenario.h>
+#include <sql.h>
+#include <clients.h>
+#include <mal_exception.h>
+
+#define LIDAR_INS_COL "INSERT INTO lidar_columns(id, name, type, units, 
number, table_id) \
+        VALUES(%d,'%s','%s','%s',%d,%d);"
+#define FILE_INS "INSERT INTO lidar_files(id, name) VALUES (%d, '%s');"
+#define DEL_TABLE "DELETE FROM lidarfiles;"
+#define ATTACHDIR "CALL lidarattach('%s');"
+
+#ifndef NDEBUG
+static
+void print_lidar_header(FILE *file, LASHeaderH header, const char* file_name, 
int bSkipVLR, int bWKT) {
+
+    char *pszSignature = NULL;
+    char *pszProjectId = NULL;
+    char *pszSystemId = NULL;
+    char *pszSoftwareId = NULL;
+    char *pszProj4 = NULL;
+    char *pszWKT = NULL;
+    char *pszVLRUser = NULL;
+    char *pszVLRDescription = NULL;
+    unsigned short nVLRLength = 0;
+    unsigned short nVLRRecordId = 0;
+    LASVLRH pVLR = NULL;
+    LASSRSH pSRS = NULL;
+    unsigned int nVLR = 0;
+    int i = 0;
+
+    char minor, major;
+
+    pszSignature = LASHeader_GetFileSignature(header);
+    pszProjectId = LASHeader_GetProjectId(header);
+    pszSystemId = LASHeader_GetSystemId(header);
+    pszSoftwareId = LASHeader_GetSoftwareId(header);
+
+    pSRS = LASHeader_GetSRS(header);
+    pszProj4 = LASSRS_GetProj4(pSRS);
+    pszWKT = LASSRS_GetWKT_CompoundOK(pSRS);
+
+    nVLR = LASHeader_GetRecordsCount(header);
+    major = LASHeader_GetVersionMajor(header);
+    minor = LASHeader_GetVersionMinor(header);
+
+    fprintf(file, 
"\n---------------------------------------------------------\n");
+    fprintf(file, "  Header Summary\n");
+    fprintf(file, 
"---------------------------------------------------------\n");
+
+    fprintf(file, "  File Name: %s\n", file_name);
+
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to