Unverified Commit 3d209ef9 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #7001 from DonLakeFlyer/PolygonFromSHP

Polygon: Support loading from SHP files
parents e42fd916 899d58bc
......@@ -14,6 +14,7 @@ Note: This file only contains high level features or important fixes.
* Edit Position dialog available on polygon vertices.
* Fixed Wing Landing Pattern: Add stop photo/video support. Defaults to on such that doing an RTL will stop camera.
* Survey Planning: add mode that supports concave polygons
* Support loading polygons from SHP files
## 3.4
......
......@@ -89,6 +89,13 @@ exists($$MAVLINKPATH/common) {
INCLUDEPATH += libs/eigen
DEFINES += NOMINMAX
#
# [REQUIRED] shapelib library
INCLUDEPATH += libs/shapelib
SOURCES += \
libs/shapelib/shpopen.c \
libs/shapelib/safileio.c
#
# [REQUIRED] QWT plotting library dependency. Provides plotting capabilities.
#
......
Frank Warmerdam <warmerdam@pobox.com> et al.
# Top-level CMakeLists.txt for the CMake-based build and test system
# of the shapelib software.
# Copyright (C) 2012-2013 Alan W. Irwin
# See README.CMake
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as published
# by the Free Software Foundation; version 2 of the License.
#
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with this file; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# It is a fatal error if no working C compiler is available to build
# the shapelib library and utilities
project(shapelib C)
message(STATUS "CMake version = ${CMAKE_VERSION}")
message(STATUS "CMAKE_SYSTEM_NAME = ${CMAKE_SYSTEM_NAME}")
# Version 2.8.5 or above of cmake is currently required for all platforms.
cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR)
# libraries are all shared by default.
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
# Use rpath?
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# No rpath on Darwin. Setting it will only cause trouble.
else(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
option(USE_RPATH "Use -rpath when linking libraries, executables" ON)
endif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# In windows all created dlls are gathered in the dll directory
# if you add this directory to your PATH all shared libraries are available
if(BUILD_SHARED_LIBS AND WIN32 AND NOT CYGWIN)
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/dll)
endif(BUILD_SHARED_LIBS AND WIN32 AND NOT CYGWIN)
set(PACKAGE shp)
# Set up install locations.
set(
CMAKE_INSTALL_BINDIR
${CMAKE_INSTALL_PREFIX}/bin
CACHE PATH "install location for user executables"
)
set(
CMAKE_INSTALL_LIBDIR
${CMAKE_INSTALL_PREFIX}/lib
CACHE PATH "install location for object code libraries"
)
set(
CMAKE_INSTALL_INCLUDEDIR
${CMAKE_INSTALL_PREFIX}/include
CACHE PATH "install location for C header files"
)
set(
CMAKE_INSTALL_SHP_DATADIR
${CMAKE_INSTALL_PREFIX}/share/${PACKAGE}
CACHE PATH "install location for read-only architecture-independent shp data"
)
# Export build information to help other projects link installed
# shapelib software. Only one of these signatures is required
# for the export_shp name.
install(EXPORT export_shp DESTINATION ${CMAKE_INSTALL_SHP_DATADIR})
# Initial boilerplate done, now build library and executables.
set(lib_SRC
shpopen.c
dbfopen.c
safileio.c
shptree.c
sbnsearch.c
)
option(SHP_DROP_UNABLE_TO_OPEN_MSG "Drop \"unable to open\" error messages" ON)
if(SHP_DROP_UNABLE_TO_OPEN_MSG)
#define the SHP_DROP_UNABLE_TO_OPEN_MSG C macro for this source file.
set_source_files_properties(shpopen.c
PROPERTIES
COMPILE_DEFINITIONS SHP_DROP_UNABLE_TO_OPEN_MSG
)
endif(SHP_DROP_UNABLE_TO_OPEN_MSG)
add_library(shp ${lib_SRC})
if(WIN32 AND NOT CYGWIN)
set_target_properties(shp
PROPERTIES
COMPILE_DEFINITIONS SHAPELIB_DLLEXPORT
)
endif(WIN32 AND NOT CYGWIN)
if(UNIX)
find_library(M_LIB m)
if(M_LIB)
TARGET_LINK_LIBRARIES(shp -lm)
endif()
endif(UNIX)
set(shp_SOVERSION 1)
set(shp_VERSION 1.4.1)
set_target_properties(shp
PROPERTIES
SOVERSION ${shp_SOVERSION}
VERSION ${shp_VERSION}
INSTALL_NAME_DIR "${CMAKE_INSTALL_LIBDIR}"
)
if(USE_RPATH)
set_target_properties(shp
PROPERTIES
INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}"
)
endif(USE_RPATH)
install(TARGETS shp
EXPORT export_shp
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
# executables to be built and installed.
set(executables
shpcreate
shpadd
shpdump
shprewind
dbfcreate
dbfadd
dbfdump
shptreedump
)
find_program(BASH_EXECUTABLE bash)
find_program(SED_EXECUTABLE sed)
if(BASH_EXECUTABLE AND SED_EXECUTABLE)
set(BUILD_TEST ON)
else(BASH_EXECUTABLE AND SED_EXECUTABLE)
message(STATUS "WARNING: sed or bash not available so disabling testing")
endif(BASH_EXECUTABLE AND SED_EXECUTABLE)
# For the first series of tests, the user needs to have downloaded
# from http://dl.maptools.org/dl/shapelib/shape_eg_data.zip, unpacked
# that file, and specified the location of that directory with
# the cmake option, -DEG_DATA:PATH=whatever
if(BUILD_TEST)
if(EG_DATA)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/script.sed "s?/u/www/projects/shapelib/eg_data?${EG_DATA}?\n")
else(EG_DATA)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/script.sed "")
message(STATUS "WARNING: EG_DATA:PATH not set to point to downloaded eg_data directory so the eg_data part of testing will be ignored.")
endif(EG_DATA)
endif(BUILD_TEST)
foreach(executable ${executables})
add_executable(${executable} ${executable}.c)
target_link_libraries(${executable} shp)
if(USE_RPATH)
set_target_properties(${executable}
PROPERTIES
INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}"
)
endif(USE_RPATH)
if(BUILD_TEST)
get_target_property(${executable}_LOC ${executable} LOCATION)
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/script.sed "s?\\./${executable}?${${executable}_LOC}?\n")
endif(BUILD_TEST)
install(TARGETS ${executable} DESTINATION ${CMAKE_INSTALL_BINDIR})
endforeach(executable ${executables})
# Install header
install(FILES shapefil.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
if(BUILD_TEST)
# Set up tests:
enable_testing()
# Other executables to be built to facilitate tests.
foreach(executable shptest shputils)
add_executable(${executable} ${executable}.c)
target_link_libraries(${executable} shp)
get_target_property(${executable}_LOC ${executable} LOCATION)
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/script.sed "s?\\./${executable}?${${executable}_LOC}?\n")
endforeach(executable shptest shputils)
# Write this as a shell script since execute_process cannot handle
# anything like redirection.
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/script.sh "${SED_EXECUTABLE} -f script.sed < $1 >| $2")
execute_process(
COMMAND
${BASH_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/script.sh ${CMAKE_CURRENT_SOURCE_DIR}/tests/test1.sh ${CMAKE_CURRENT_BINARY_DIR}/sed_scripted_test1.sh
)
execute_process(
COMMAND
${BASH_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/script.sh ${CMAKE_CURRENT_SOURCE_DIR}/tests/test2.sh ${CMAKE_CURRENT_BINARY_DIR}/sed_scripted_test2.sh
)
execute_process(
COMMAND
${BASH_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/script.sh ${CMAKE_CURRENT_SOURCE_DIR}/tests/test3.sh ${CMAKE_CURRENT_BINARY_DIR}/sed_scripted_test3.sh
)
if(EG_DATA)
# These tests correspond to everything in test1.sh
add_test(
NAME test1
COMMAND ${BASH_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/sed_scripted_test1.sh
)
endif(EG_DATA)
# These tests correspond to everything in test2.sh
add_test(
NAME test2
COMMAND ${BASH_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/sed_scripted_test2.sh
)
# These tests correspond to everything in test3.sh
add_test(
NAME test3
COMMAND ${BASH_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/sed_scripted_test3.sh
)
endif(BUILD_TEST)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
## Process this file with automake to produce Makefile.in
SUBDIRS = . contrib
ACLOCAL_AMFLAGS = -I m4
AUTOMAKE_OPTIONS = dist-zip
if PLATFORM_WIN32
no_undefined = -no-undefined
endif
# Extra files to distribute in the source tarball
EXTRA_DIST = makefile.vc CMakeLists.txt autogen.sh \
tests/test1.sh tests/test2.sh tests/test3.sh \
tests/stream1.out tests/stream1.out tests/stream1.out \
web/maptools.css \
web/codepage.html \
web/index.html \
web/shapelib-tools.html \
web/shp_api.html \
web/release.html \
web/dbf_api.html \
web/license.html \
web/manifest.html \
README.tree README.CMake
# pkg-config file
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = shapelib.pc
# Library
lib_LTLIBRARIES = libshp.la
libshp_la_includedir = $(includedir)
libshp_la_include_HEADERS = shapefil.h
libshp_la_SOURCES = shpopen.c dbfopen.c safileio.c shptree.c sbnsearch.c
libshp_la_LDFLAGS = -version-info $(SHAPELIB_SO_VERSION) $(no_undefined) $(LIBM)
# Installed executables
bin_PROGRAMS = dbfadd dbfcreate dbfdump shpadd shpcreate shpdump shprewind shptreedump shputils
dbfadd_SOURCES = dbfadd.c
dbfadd_LDADD = $(top_builddir)/libshp.la
dbfcreate_SOURCES = dbfcreate.c
dbfcreate_LDADD = $(top_builddir)/libshp.la
dbfdump_SOURCES = dbfdump.c
dbfdump_LDADD = $(top_builddir)/libshp.la
shpadd_SOURCES = shpadd.c
shpadd_LDADD = $(top_builddir)/libshp.la
shpcreate_SOURCES = shpcreate.c
shpcreate_LDADD = $(top_builddir)/libshp.la
shpdump_SOURCES = shpdump.c
shpdump_LDADD = $(top_builddir)/libshp.la
shprewind_SOURCES = shprewind.c
shprewind_LDADD = $(top_builddir)/libshp.la
shptreedump_SOURCES = shptreedump.c
shptreedump_LDADD = $(top_builddir)/libshp.la
shputils_SOURCES = shputils.c
shputils_LDADD = $(top_builddir)/libshp.la
# Non-installed executables
noinst_PROGRAMS = shptest
shptest_SOURCES = shptest.c
shptest_LDADD = $(top_builddir)/libshp.la
# Tests
TESTS_ENVIRONMENT = top_builddir=$(abs_top_builddir)
# tests/test1.sh requires ftp://gdal.velocet.ca/pub/outgoing/shape_eg_data.zip
TESTS = tests/test2.sh tests/test3.sh
This diff is collapsed.
Building on Unix
----------------
1) run ./configure to generate build scripts
Note: type ./configure --help for a list of fine-tuning options
2) type "make"
3) type "make check" to perform self-tests
4) type "make install" to install
Building on Windows
-------------------
If you have run the VC++ VCVARS32.BAT, you should be able to type the
following in a command window to build the code and executables:
C:> nmake /f makefile.vc
Otherwise create your own VC++ project. There aren't many files to deal with
here!
The CMakeLists.txt file in the current directory is a complete build
system for shapelib which does everything that the shapelib Makefile
does and Linux and the shapelib makefile.vc file does on Windows with
a lot more flexibility. For example, full testing can be done with
the present CMake-based approach because an optional and configurable
location is used for the downloadable (for example, wget
http://dl.maptools.org/dl/shapelib/shape_eg_data.zip) eg_data tree
that is used for all the "stream1" tests.
To use this build system on Unix or MinGW/MSYS/Windows:
(1) (Optional) Download eg_data from the location above.
(2) Download shapelib-1.3.0.tar.gz from http://download.osgeo.org/shapelib
and unpack it
(3) Copy the CMakeLists.txt file into the top-level of the unpacked
shapelib-1.3.0 source tree.
(4) Apply shapelib.patch (which optionally quiets error messages when
shapelib is unable to open shapefiles). First change directory
to the top-level of the shapelib-1.3.0 source tree, then
patch -p1 < <full path to shapelib.patch>
(5) Create a separate empty build tree and use it to configure, build,
install and test shapelib. For example (you will need to tailor the
compiler, compile options, install prefix, eg_data location, and source tree location to your own
needs):
mkdir build_dir
cd build_dir
# Configure with the compiler and compiler options of your choice.
# N.B. the gcc -fvisibility=hidden option not (yet) supported by shapelib.
env CC=gcc CFLAGS="-O3 -Wuninitialized" \
cmake \
-G "Unix Makefiles" \
-DCMAKE_INSTALL_PREFIX=/home/software/shapelib/install \
-DEG_DATA:PATH=/home/software/shapefile/eg_data/ \
../shapelib-1.3.0 >& cmake.out
# Build and install
make VERBOSE=1 -j4 install >& install.out
# Test
ctest
The -DEG_DATA:PATH option is optional, but if you don't specify
the eg_data directory that way the stream1 tests will be dropped.
Note the above procedure is what you should do on a Unix platform like
Linux where the generator -G "Unix Makefiles" works well. On
MINGW/MSYS the procedure is essentially the same except you should use
the -G "MSYS Makefiles" cmake option instead to specify a good generator
for that platform.
I have used variants of the above procedure to create, test, and
install shapelib on both the Linux and MinGW/MSYS/Wine platforms.
Furthermore, on both platforms I have built and tested PLplot using
the installed versions created by the above procedure. No issues were
discovered with PLplot example 19 (which demos PLplot map capabilities with
map shapefiles) for these two separate platform tests.
Venkat,
I have completed the planned Shapefile quadtree mechanism. The additions
to the traditional Shapelib are found in shptree.c (functions supporting
quad tree searching and query). There are also some new prototypes for
the tree stuff in shapefil.h ... including some prototypes for functions
you don't require and hence that I haven't implemented at this time.
I have also prepared a demonstration program using the API. That is
the ``shpdumptree'' program, with the source code in shpdumptree.c. The
shpdumptree program has two functions. One is to dump an ASCII rendering
of the internal quadtree, and the other is example use of a quad tree
searching function.
Dumping the Tree
----------------
The tree dumping is done as shown below. The "-maxdepth" commandline
switch can be used to control the maximum depth, otherwise it internally
computes a ``reasonable depth'' to use based on the number of structures
in the shapefile.
warmerda@gdal[207]% shptreedump -maxdepth 6 eg_data/polygon.shp
( SHPTreeNode
Min = (471127.19,4751545.00)
Max = (489292.31,4765610.50)
Shapes(0):
( SHPTreeNode
Min = (471127.19,4751545.00)
Max = (481118.01,4765610.50)
Shapes(0):
( SHPTreeNode
Min = (471127.19,4751545.00)
Max = (481118.01,4759281.03)
Shapes(0):
( SHPTreeNode
Min = (471127.19,4751545.00)
Max = (476622.14,4759281.03)
Shapes(0):
( SHPTreeNode
Min = (471127.19,4751545.00)
Max = (476622.14,4755799.81)
Shapes(0):
( SHPTreeNode
Min = (471127.19,4751545.00)
Max = (474149.41,4755799.81)
Shapes(6): 395 397 402 404 405 422
)
( SHPTreeNode
Min = (473599.92,4751545.00)
Max = (476622.14,4755799.81)
Shapes(10): 392 394 403 413 414 417 426 433 434 447
)
)
...
A structure like the following represents one node in the tree. In
this case it cover the region of 473599.92 < X < 476622.14,and
4751545.0 < Y < 4755799.81. There are ten shapes within this region
who's shapeids are 392, 394 ... 447. This node has no children nodes.
( SHPTreeNode
Min = (473599.92,4751545.00)
Max = (476622.14,4755799.81)
Shapes(10): 392 394 403 413 414 417 426 433 434 447
)
The heirarchy of indentation is intended to show the parent, child
relationship between nodes, with the tree being deeper the further to the
right you go.
The `-v' flag to the program can be used to expand the report to include
the full information about shapes, not just their shapeid. This can result
in a report looking more like this:
...
( SHPTreeNode
Min = (478095.78,4751545.00)
Max = (481118.01,4755799.81)
Shapes(3):
( Shape
ShapeId = 448
Min = (479988.09,4753300.00)
Max = (480705.59,4754236.50)
Vertex[0] = (480136.59,4754174.50)
Vertex[1] = (480229.97,4754182.00)
Vertex[2] = (480370.09,4754200.50)
Vertex[3] = (480695.12,4754236.50)
Vertex[4] = (480687.97,4754129.50)
Vertex[5] = (480650.47,4754075.50)
Vertex[6] = (480520.62,4753948.00)
Vertex[7] = (480490.00,4753900.00)
Vertex[8] = (480499.78,4753840.50)
Vertex[9] = (480500.97,4753820.50)
Vertex[10] = (480534.75,4753660.50)
Vertex[11] = (480560.00,4753565.00)
Vertex[12] = (480574.91,4753550.50)
...
While it is possible to part the output of the shptreedump program, and
insert it into your database, my intention was that the shptreedump program
would serve as an example of how to pre-order traversal of the quad tree,
and collect the information you will need to insert into your database.
I would then expect you to write a new program based on shptreedump that
calls a C API for your database to insert objects instead of printing them
out. Alternatively there may be an ASCII format for loading tables that
you could modify the program to output.
Searching
---------
The other thing that you can do with the shptreedump program is to
perform a search on the quadtree. For instance the following shows
searching on a small region.
% shptreedump -search 471127 4751545 476622 4759281 eg_data/polygon.shp
Shape 17: not in area of interest, but fetched.
Shape 31: not in area of interest, but fetched.
Shape 52: not in area of interest, but fetched.
Shape 76: not in area of interest, but fetched.
Shape 82: not in area of interest, but fetched.
Shape 104: not in area of interest, but fetched.
Shape 124: not in area of interest, but fetched.
Shape 134: not in area of interest, but fetched.
Shape 139: not in area of interest, but fetched.
Shape 154: not in area of interest, but fetched.
Shape 175: not in area of interest, but fetched.
Shape 177: not in area of interest, but fetched.
Shape 185: not in area of interest, but fetched.
Shape 192: not in area of interest, but fetched.
Shape 196: appears to be in area of interest.
....
I have included this capability (and the SHPTreeFindLikelyShapes() function)
so that you can see a working example of how to search this quad tree.
Note that searching is a multi-stage affair.
First a pass is made over the quadtree, collecting the shapeids of all
shapes contained in a quadtree node for which the bounding rectangle overlaps
the search rectangle. This is all accomplished by SHPTreeFindLikelyShapes()
in shptree.c.
The second phase is to fetch the actual shapes, and verify if their bounding
box falls within the area of interest. This is necessary because the shape
will tend to have a significantly smaller bounding rectangle than the tree
node in which it is found. This can result ``false positives'' on the first
phase search, as indicated by teh ``not in area of interest, but fetched''
messages above. This stage is done in the SHPTreeNodeSearchAndDump()
function in shptreedump.c.
A possible third phase is to verify that the actualy line segments in the
shape actually cross the area of interest. I don't both with this as it
is complicated, and assuming that the drawing engine takes care of clipping
it is quite a bit easier to let it fall through.
Building
--------
I have added a makefile.vc to the shapelib distribution. After you have
unpacked the shapefile you should have a shapelib subdirectory. If you
cd to that directory, and enter ``nmake -f makefile.vc'' in a DOS window
you should be able to build everything with VC++ (assuming it is properly
installed and in your path).
You can also create a project in VC just including the files
shpopen.c, shptree.c and shptreedump.c, building as a Win32 console
application.
For your convenience I am including prebuild .obj files, and .exe files
in the distribution.
This diff is collapsed.
This diff is collapsed.
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
srcdir="$(dirname "$(readlink -f $0)")"
(test -f $srcdir/configure.ac) || {
echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
echo " top-level package directory"
echo
exit 1
}
(libtool --version) < /dev/null > /dev/null 2>&1 || {
echo "**Error**: You must have \`libtool' installed."
echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/"
echo
exit 1
}
(autoreconf --version) < /dev/null > /dev/null 2>&1 || {
echo "**Error**: You must have \`autoreconf' installed."
echo "Download the appropriate package for your distribution,"
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
echo
exit 1
}
(
cd "$srcdir"
echo "Running autoreconf..."
autoreconf -fiv
)
if test x$NOCONFIGURE = x; then
echo Running $srcdir/configure "$@" ...
$srcdir/configure "$@" \
&& echo Now type \`make\' to compile. || exit 1
else
echo Skipping configure process.
fi
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
dnl Process this file with autoconf to produce a configure script.
m4_define(shapelib_version_major, 1)
m4_define(shapelib_version_minor, 4)
m4_define(shapelib_version_micro, 1)
AC_PREREQ(2.62)
AC_INIT(shapelib, shapelib_version_major.shapelib_version_minor.shapelib_version_micro)
AC_CONFIG_MACRO_DIR(m4)
AC_CONFIG_SRCDIR(shapefil.h)
AM_INIT_AUTOMAKE([-Wall])
AM_SILENT_RULES([yes])
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
dnl See http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
AC_SUBST([SHAPELIB_SO_VERSION], [2:2:0])
AC_PROG_CC
AC_PROG_CXX
AM_PROG_CC_C_O
AC_LANG([C])
AC_LANG([C++])
dnl ************************** Libtool initialization *************************
LT_INIT
dnl ********************************* Modules *********************************
AC_ARG_WITH([proj-cflags],
[AS_HELP_STRING([--with-proj-cflags], [CFLAGS for the PROJ.4 headers])],
[if test "$withval" != ""; then PROJ_CFLAGS="$withval"; else PROJ_CFLAGS=""; fi],
[PROJ_CFLAGS='-DPROJ4'])
AC_SUBST([PROJ_CFLAGS])
AC_ARG_WITH([proj-libs],
[AS_HELP_STRING([--with-proj-libs], [LIBS for the PROJ.4 libraries])],
[PROJ_LIBS="$withval"],
[PROJ_LIBS='-lproj'])
AC_SUBST([PROJ_LIBS])
dnl ****************************** Detect libm *******************************
AC_CHECK_LIB(m,floor,LIBM=-lm)
AC_SUBST([LIBM])
dnl ****************************** Detect Win32 *******************************
AC_MSG_CHECKING([for some Win32 platform])
case "$host" in
*-*-mingw*|*-*-cygwin*)
platform_win32=yes
;;
*)
platform_win32=no
;;
esac
AC_MSG_RESULT([$platform_win32])
AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = "yes")
dnl ********************************* Summary *********************************
echo
echo "Configuration summary for $PACKAGE $VERSION:"
echo " - Host: ${host}"
echo " - PROJ flags: $PROJ_CFLAGS $PROJ_LIBS"
echo
AC_CONFIG_FILES([Makefile contrib/Makefile shapelib.pc])
AC_OUTPUT
CONTRIB_CFLAGS = -I$(top_srcdir) -DDEBUG -DDEBUG2
# Extra files to distribute in the source tarball
EXTRA_DIST = makefile.vc tests/shpproj.sh doc/Shape_PointInPoly_README.txt doc/shpproj.txt doc/shpsort.txt ShapeFileII.pas
# Installed executables
bin_PROGRAMS = dbfcat dbfinfo shpcat shpdxf shpfix shpsort Shape_PointInPoly shpcentrd shpdata shpinfo shpproj shpwkb
dbfcat_SOURCES = dbfcat.c
dbfcat_CPPFLAGS = $(CONTRIB_CFLAGS)
dbfcat_LDADD = $(top_builddir)/libshp.la
dbfinfo_SOURCES = dbfinfo.c
dbfinfo_CPPFLAGS = $(CONTRIB_CFLAGS)
dbfinfo_LDADD = $(top_builddir)/libshp.la
shpcat_SOURCES = shpcat.c
shpcat_CPPFLAGS = $(CONTRIB_CFLAGS)
shpcat_LDADD = $(top_builddir)/libshp.la
shpdxf_SOURCES = shpdxf.c
shpdxf_CPPFLAGS = $(CONTRIB_CFLAGS)
shpdxf_LDADD = $(top_builddir)/libshp.la
shpfix_SOURCES = shpfix.c
shpfix_CPPFLAGS = $(CONTRIB_CFLAGS)
shpfix_LDADD = $(top_builddir)/libshp.la
shpsort_SOURCES = shpsort.c
shpsort_CPPFLAGS = $(CONTRIB_CFLAGS)
shpsort_LDADD = $(top_builddir)/libshp.la -lm
Shape_PointInPoly_SOURCES = Shape_PointInPoly.cpp
Shape_PointInPoly_CPPFLAGS = $(CONTRIB_CFLAGS)
Shape_PointInPoly_LDADD = $(top_builddir)/libshp.la
shpcentrd_SOURCES = shpcentrd.c shpgeo.c shpgeo.h
shpcentrd_CPPFLAGS = $(CONTRIB_CFLAGS) $(PROJ_CFLAGS)
shpcentrd_LDADD = $(top_builddir)/libshp.la $(PROJ_LIBS) -lm
shpdata_SOURCES = shpdata.c shpgeo.c shpgeo.h
shpdata_CPPFLAGS = $(CONTRIB_CFLAGS) $(PROJ_CFLAGS)
shpdata_LDADD = $(top_builddir)/libshp.la $(PROJ_LIBS) -lm
shpinfo_SOURCES = shpinfo.c shpgeo.c shpgeo.h
shpinfo_CPPFLAGS = $(CONTRIB_CFLAGS) $(PROJ_CFLAGS)
shpinfo_LDADD = $(top_builddir)/libshp.la $(PROJ_LIBS) -lm
shpproj_SOURCES = shpproj.c shpgeo.c shpgeo.h
shpproj_CPPFLAGS = $(CONTRIB_CFLAGS) $(PROJ_CFLAGS)
shpproj_LDADD = $(top_builddir)/libshp.la $(PROJ_LIBS) -lm
shpwkb_SOURCES = shpwkb.c shpgeo.c shpgeo.h
shpwkb_CPPFLAGS = $(CONTRIB_CFLAGS) $(PROJ_CFLAGS)
shpwkb_LDADD = $(top_builddir)/libshp.la $(PROJ_LIBS) -lm
# Tests
TESTS_ENVIRONMENT = top_builddir=$(abs_top_builddir)
TESTS = tests/shpproj.sh
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
===============================================================================
Project: Shape_PoinInPoly
Purpose: Sample and the function for calculatin a point in a polygon
(complex,compound - it doesn't matter). Can be used for labeling.
Author: Copyright (c) 2004, Marko Podgorsek, d-mon@siol.net
===============================================================================
Requires: shapelib 1.2 (http://shapelib.maptools.org/)
Tested and created on platform:
Windows 2000 Professional
Visual Studio .NET 7.0
P4 2.4 GHz
1GB RAM
I just found out about the ShapeLib, GDAL and OGR and I must say that they're
all great projects.
I belive I'll use some of those libraries in the future. Right now I'm using
only shapelib.
The thing that led me to the http://wwww.maptools.org was the need of finding
the point in poly...but as I found out that even OGR didn't support it. So
there I was. I was forced to make my own function. Well, it was fun. I learned
a lot.
I wrote this function for the Autodesk Autocad 2004 MPolygon, because there was
no function to do this in the Object Arx SDK (the Acad programming SDK). Well,
it will be in the 2005 release...but, still. There is a function in the
Autodesk Map 2004 version...in the menu.
Not useful when you need the coordinates, not the point on the screen...
So when the Acad version was done I was thinking of doing it on the Shape files,
too. A little bit of changing the structures and variable
types (so they're not using Object Arx) and I was done.
And here it is....Contribution from me to the ShapeLib world :)...and maybe even
OGR (a little bit of changing there).
Some statistics:
For about 69000 polygons in Autocad picture (.dwg files)
Autodesk Map 2004 was creating centroids (the menu command) about 45s (1 scan
line)
My function, with 3 scan lines took about 5s. And I was drawing the dots on the
picture...
-------------------------------------------------------------------------------
DPoint2d CreatePointInPoly(SHPObject *psShape, int quality)
The second parameter quality tell the function just how many rays shall it use
to get the point.
quality = 3 works very well, but anything below 5 is good.
This doesn't mean that the execution will slow down, but it just finds a good
point. That's all.
The qality shows on the compound objects (multiple poligons with more than one
exterior loop) - if not enough rays, then there may be no centroid.
Or the U shaped thin polygon, only the bootom (below the y center line) is fat.
Autodesk Map with one scan line will create the centroid on one of the thin
parts, because it only uses the y center line. If you have more rays, one will
surely pass the fat area and centroid will be created there.
-------------------------------------------------------------------------------
Anyone using this function:
Just send me an e-mail, so I'll see if I did anything good for the public.
And you can send me e-mail with questions also.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
datarootdir=@datarootdir@
datadir=@datadir@
includedir=@includedir@
Name: shapelib
Description: C API for processing ESRI Shapefiles
Version: @VERSION@
Libs.private: @PROJ_LIBS@
Cflags.private: @PROJ_CFLAGS@
Libs: -L${libdir} -lshp
Cflags: -I${includedir}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment