]> granicus.if.org Git - postgis/commitdiff
Some function renaming: lwgeom_typename => lwtype_name. The internal float/up/down...
authorPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 16 Mar 2010 03:13:33 +0000 (03:13 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 16 Mar 2010 03:13:33 +0000 (03:13 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@5439 b70326c6-7e19-0410-871a-916f4a2858ee

50 files changed:
ChangeLog
liblwgeom/g_serialized.c
liblwgeom/g_util.c
liblwgeom/libgeom.h
liblwgeom/liblwgeom.h
liblwgeom/lwcircstring.c
liblwgeom/lwcollection.c
liblwgeom/lwcompound.c
liblwgeom/lwcurvepoly.c
liblwgeom/lwgeodetic.c
liblwgeom/lwgeom.c
liblwgeom/lwgeom_api.c
liblwgeom/lwgunparse.c
liblwgeom/lwhomogenize.c
liblwgeom/lwline.c
liblwgeom/lwmcurve.c
liblwgeom/lwmline.c
liblwgeom/lwmpoint.c
liblwgeom/lwmpoly.c
liblwgeom/lwmsurface.c
liblwgeom/lwout_geojson.c
liblwgeom/lwout_gml.c
liblwgeom/lwout_kml.c
liblwgeom/lwout_svg.c
liblwgeom/lwout_wkb.c
liblwgeom/lwpoint.c
liblwgeom/lwpoly.c
liblwgeom/lwprint.c
liblwgeom/lwsegmentize.c
liblwgeom/lwutil.c
liblwgeom/measures.c
liblwgeom/ptarray.c
liblwgeom/wktparse.h
loader/shp2pgsql-core.c
loader/shp2pgsql-core.h
postgis/geography_gist.c
postgis/geography_inout.c
postgis/lwgeom_chip.c
postgis/lwgeom_debug.c
postgis/lwgeom_dump.c
postgis/lwgeom_functions_analytic.c
postgis/lwgeom_functions_basic.c
postgis/lwgeom_geos.c
postgis/lwgeom_geos_clean.c
postgis/lwgeom_geos_split.c
postgis/lwgeom_gist.c
postgis/lwgeom_in_gml.c
postgis/lwgeom_in_kml.c
postgis/lwgeom_inout.c
postgis/lwgeom_ogc.c

index fecbf82a4f37c5582ec0061b7723307964e91269..34f03a99866388269696e52d6fc7b21731b91628 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2010-03-15 18:03  strk
+
+       * postgis/lwgeom_geos_split.c, postgis/postgis.sql.in.c,
+         regress/split.sql: Rename ST_SplitGeometry to ST_Split (better
+         now than never)
+
+2010-03-15 18:00  strk
+
+       * postgis/lwgeom_geos_split.c, regress/split.sql,
+         regress/split_expected: Implement split-poly-by-line
+
+2010-03-13 12:55  strk
+
+       * postgis/lwgeom_geos_split.c, regress/split.sql,
+         regress/split_expected: Reword exception message, make algorithm
+         more robust not relying on constructive functions to detect
+         relation between inputs
+
+2010-03-13 11:23  strk
+
+       * postgis/lwgeom_geos_split.c: Fix printf call
+
+2010-03-13 11:16  strk
+
+       * postgis/lwgeom_geos_split.c, regress/split.sql,
+         regress/split_expected: Split-line-by-line: handle overlap cases
+         by raising an exception
+
+2010-03-13 10:59  strk
+
+       * postgis/lwgeom_geos_split.c, regress/split.sql,
+         regress/split_expected: Implement split-line-by-line
+
+2010-03-13 09:22  strk
+
+       * postgis/lwgeom_functions_analytic.c: Be polite
+
+2010-03-12 18:39  strk
+
+       * loader/shp2pgsql-core.c: Fix memory errors in presence of NULL
+         (0-verticed) geometries and insert (default) policy.
+
+2010-03-12 15:46  strk
+
+       * liblwgeom/ptarray.c: ptarray_substring *does* already implement
+         interpolation
+
+2010-03-12 15:25  strk
+
+       * postgis/TODO: Drop extraneous task (if it referred to loader we
+         do have a switch for index creation now)
+
+2010-03-12 15:15  strk
+
+       * postgis/postgis.sql.in.c: Fix ST_DumpPoints not to relay on NULL
+         return from ST_NumGeometries to tell multi and singles apart
+
+2010-03-12 15:14  strk
+
+       * regress/Makefile.in: Trigger reconstruction of regress'
+         postgis.sql when original one changes
+
+2010-03-12 14:03  strk
+
+       * NEWS: Add item about GeometryN/NumGeometries
+
+2010-03-12 13:50  strk
+
+       * postgis/lwgeom_ogc.c, regress/regress_ogc.sql,
+         regress/regress_ogc_expected: Add support for simple geometries
+         in ST_GeometryN and ST_NumGeometries
+
+2010-03-12 13:29  mcayland
+
+       * configure.ac: Fix the PGXS override code for detecting older
+         versions of PostgreSQL - the existing (incomplete) check was
+         still checking for a minimum version of 8.5, rather
+         than the new version number of 9.0.
+
+2010-03-12 00:21  robe
+
+       * doc/reference_lrs.xml: put in note about improvement to
+         ST_Line_SubString #410
+
+2010-03-11 20:50  strk
+
+       * postgis/lwgeom_geos_split.c: More comments cleanup
+
+2010-03-11 20:48  strk
+
+       * postgis/lwgeom_geos_split.c: remove wrong comment
+
+2010-03-11 20:34  strk
+
+       * postgis/lwgeom_geos_split.c, regress/split.sql,
+         regress/split_expected: Set interface specs in stone within the
+         implementation file, add a testcase to show what's "left" and
+         what's "right" in the split-line-by-point
+
+2010-03-11 20:28  strk
+
+       * postgis/lwgeom_geos_split.c, regress/split_expected: *always*
+         return a collection from ST_SplitGeometry
+
+2010-03-11 20:19  strk
+
+       * postgis/lwgeom_geos_split.c, regress/split.sql,
+         regress/split_expected: Have ST_SplitGeometry return a collection
+         of at most 2 elements (original part, cut-away part) so it's
+         easier to handle by callers
+
+2010-03-11 17:53  strk
+
+       * regress/remove_repeated_points.sql,
+         regress/remove_repeated_points_expected: Add SRID retainment
+         testcase for removerepeatedpoint (paranoia)
+
+2010-03-11 17:51  strk
+
+       * regress/clean.sql, regress/clean_expected: Add SRID retainment
+         testcases
+
+2010-03-11 17:21  strk
+
+       * postgis/lwgeom_geos_clean.c: Don't 'clean' the SRID...
+
+2010-03-11 14:34  pramsey
+
+       * HOWTO_RELEASE: Grammar fix.
+
+2010-03-10 15:38  pramsey
+
+       * postgis/lwgeom_accum.c: Fix to allow compile on 9.0alpha
+
+2010-03-10 15:33  strk
+
+       * postgis/Makefile.in, postgis/lwgeom_geos_split.c,
+         postgis/postgis.sql.in.c, regress/Makefile.in, regress/split.sql,
+         regress/split_expected: Initial work on ST_SplitGeometry. Split
+         line by point implemented.
+
+2010-03-10 15:29  strk
+
+       * liblwgeom/liblwgeom.h, liblwgeom/ptarray.c,
+         postgis/lwgeom_functions_analytic.c: Since we do a full scan of
+         pointarray from ptarray_locate_point, take the chance to also
+         return min distance
+
+2010-03-10 14:32  strk
+
+       * liblwgeom/liblwgeom.h: Document closest_point_on_segment in
+         header file
+
+2010-03-10 14:20  strk
+
+       * liblwgeom/liblwgeom.h: Document ptarray_locate_point in header
+         file
+
+2010-03-10 10:07  strk
+
+       * postgis/lwgeom_geos.c, postgis/lwgeom_geos.h,
+         postgis/lwgeom_geos_clean.c: Export geos error logger
+
+2010-03-09 00:37  pramsey
+
+       * doc/installation.xml: Fix syntax error in spatial_ref_sys hard
+         upgrade directions (#373)
+
+2010-03-09 00:31  pramsey
+
+       * utils/postgis_proc_upgrade.pl: Include 'geography_columns' defn
+         when upgrading from <= 1.4 (#414)
+
+2010-03-09 00:22  pramsey
+
+       * postgis/postgis.sql.in.c: Quiet notices in the .sql install files
+         (#415)
+
+2010-03-08 23:28  pramsey
+
+       * liblwgeom/lwline.c, postgis/lwgeom_functions_basic.c: Update the
+         bbox when you alter the underlying geometry (#410) ST_SetPoint,
+         ST_Ad
+         dPoint, ST_RemovePoint.
+
+2010-03-08 16:37  kneufeld
+
+       * doc/using_postgis_dataman.xml: updated broken link to utmzone
+         PostGIS plpgsql helper function.
+         bug #461
+
+2010-03-05 23:31  pramsey
+
+       * README.postgis: Note minimum required versions.
+
+2010-03-05 21:49  strk
+
+       * postgis/lwgeom_ogc.c: Fix typo
+
+2010-03-05 02:35  pramsey
+
+       * liblwgeom/cunit/cu_wkb.c: A few more WKB unit tests.
+
+2010-03-04 09:40  colivier
+
+       * doc/reference_editor.xml: Add ST_PointN xref in ST_SetPoint
+         entry, from Bruno Friedmann report
+
+2010-03-03 06:10  pramsey
+
+       * liblwgeom/lwhomogenize.c, liblwgeom/lwout_geojson.c,
+         liblwgeom/lwout_gml.c, liblwgeom/lwout_kml.c,
+         liblwgeom/lwout_svg.c, liblwgeom/lwout_wkb.c,
+         liblwgeom/lwout_wkt.c, liblwgeom/lwprint.c: Set keywords.
+
+2010-03-03 06:10  pramsey
+
+       * liblwgeom/cunit/cu_geodetic_data.h,
+         liblwgeom/cunit/cu_homogenize.c,
+         liblwgeom/cunit/cu_out_geojson.c, liblwgeom/cunit/cu_out_gml.c,
+         liblwgeom/cunit/cu_out_kml.c, liblwgeom/cunit/cu_out_svg.c,
+         liblwgeom/cunit/cu_print.c, liblwgeom/cunit/cu_tester.c,
+         liblwgeom/cunit/cu_tester.h, liblwgeom/cunit/cu_wkb.c,
+         liblwgeom/cunit/cu_wkt.c: Set keywords and some copyright
+         headers.
+
+2010-03-03 06:06  pramsey
+
+       * liblwgeom/cunit/cu_wkb.c, liblwgeom/lwout_wkb.c: Add some tests
+         of the old versus new WKB output.
+
+2010-03-03 06:06  pramsey
+
+       * postgis/geography_measurement.c: Move spheroid test to the
+         correct place.
+
+2010-03-03 05:40  pramsey
+
+       * liblwgeom/lwout_wkb.c, liblwgeom/lwout_wkt.c: Remove doxygen
+         flags from static functions.
+
+2010-03-03 05:38  pramsey
+
+       * liblwgeom/lwout_wkb.c, liblwgeom/lwout_wkt.c: Add some
+         documentation to the public functions.
+
+2010-03-03 01:15  pramsey
+
+       * liblwgeom/cunit/Makefile.in, liblwgeom/cunit/cu_tester.c,
+         liblwgeom/cunit/cu_wkb.c, liblwgeom/libgeom.h,
+         liblwgeom/lwout_wkb.c, liblwgeom/lwout_wkt.c: Add in tests and
+         fixes for WKB emitter.
+
+2010-03-02 23:18  pramsey
+
+       * liblwgeom/Makefile.in, liblwgeom/cunit/cu_libgeom.c,
+         liblwgeom/cunit/cu_wkt.c, liblwgeom/libgeom.h,
+         liblwgeom/liblwgeom.h, liblwgeom/lwout_wkb.c,
+         liblwgeom/lwout_wkt.c: Add first cut to lwgeom_to_wkb function.
+
+2010-03-02 23:16  pramsey
+
+       * liblwgeom/stringbuffer.c, liblwgeom/stringbuffer.h: Add a couple
+         functions (length, copy) to stringbuffer, and add comments.
+
+2010-03-02 21:32  strk
+
+       * postgis/lwgeom_geos_clean.c, regress/clean.sql,
+         regress/clean_expected: ST_MakeValid : turn collapsed lines into
+         points [RT-SIGTA]
+
+2010-02-28 23:11  strk
+
+       * postgis/lwgeom_geos_clean.c, regress/Makefile.in,
+         regress/clean.sql, regress/clean_expected: Node lineal geometries
+         resulting invalid. Re-enable automated testcase for st_MakeValid
+         [RT-SIGTA]
+
+2010-02-28 22:48  strk
+
+       * postgis/lwgeom_geos_clean.c: Don't use a collection when there's
+         no area
+
+2010-02-28 22:24  strk
+
+       * postgis/lwgeom_geos_clean.c: Fix build with debugging on, fix bug
+         when run against invalid linestrings
+
+2010-02-28 21:31  strk
+
+       * postgis/lwgeom_geos_clean.c: Add paranoid check to make
+         super-sure no input vertices are dropped by ST_MakeValid
+         [RT-SIGTA]
+
+2010-02-28 20:36  strk
+
+       * postgis/lwgeom_geos_clean.c: Put GEOS-only functionality of
+         ST_MakeValid in its own function
+
+2010-02-28 19:24  strk
+
+       * postgis/lwgeom_geos_clean.c: Fix documentation to match current
+         behaviour
+
+2010-02-28 19:09  strk
+
+       * postgis/lwgeom_geos_clean.c: Simplify code
+
+2010-02-28 19:04  strk
+
+       * postgis/lwgeom_geos.c: Avoid a call to the GEOS CAPI when
+         unnecessary (works around a bug in GEOS aborting in some cases of
+         EMPTY polygons
+
+2010-02-28 17:20  strk
+
+       * postgis/lwgeom_geos_clean.c: Move ST_CleanGeometry core code into
+         specialized 'lwgeom' function
+
+2010-02-28 17:11  strk
+
+       * postgis/lwgeom_geos_clean.c: cleanups
+
+2010-02-28 14:05  strk
+
+       * postgis/lwgeom_geos_clean.c: Put areal part first in collection,
+         and collapsed edges second
+
+2010-02-26 15:05  colivier
+
+       * GNUmakefile, doc/Makefile.in, regress/Makefile.in: Add new 'make
+         garden' rule to launch full Garden test regression tests
+
+2010-02-26 02:50  pramsey
+
+       * liblwgeom/cunit/Makefile.in, liblwgeom/cunit/README,
+         liblwgeom/cunit/cu_tester.h: Instructions on adding new tests to
+         cunit, from Jeff Adams.
+
+2010-02-26 00:16  colivier
+
+       * liblwgeom/lwgeom.c, regress/tickets_expected: Add few more
+         lwgeom_typename, and update regress test if needed. Restore
+         initial lwnotice behaviour in remove_repeated_points on unknown
+         types (instead of lwerror).
+
+2010-02-25 17:54  colivier
+
+       * liblwgeom/lwgeom.c: Fix add forgotten return in flip_coordinates
+         (cf #452). Add lwgeom_typename in several functions to avoid
+         cryptic error message (#452 again).
+
+2010-02-25 15:13  pramsey
+
+       * liblwgeom/cunit/cu_geodetic.c, liblwgeom/lwgeodetic.c: Fix
+         potential corner case in sphere area calculation (#451)
+
+2010-02-25 14:30  robe
+
+       * doc/reference_processing.xml: Put new functions in alphabetical
+         order.
+
+2010-02-25 14:23  robe
+
+       * doc/xsl/postgis_aggs_mm.xml.xsl: Put in What is new in 2.0
+         section to trap new 2.0 enhancements
+
+2010-02-25 14:11  colivier
+
+       * doc/installation.xml: Add libxml2 requirement para. Fix #344.
+         Thanks to Mateus for report.
+
+2010-02-25 13:41  pramsey
+
+       * liblwgeom/cunit/cu_geodetic.c, liblwgeom/lwgeodetic.c,
+         liblwgeom/lwspheroid.c: Fix for st_area(geography) over the
+         dateline (#450)
+
+2010-02-25 13:38  colivier
+
+       * doc/reference_processing.xml, liblwgeom/cunit/cu_libgeom.c,
+         liblwgeom/liblwgeom.h, liblwgeom/lwgeom.c, liblwgeom/ptarray.c,
+         postgis/lwgeom_functions_basic.c, postgis/lwgeom_in_gml.c,
+         postgis/postgis.sql.in.c: rename ptarray_reverse_axis to
+         ptarray_flip_coordinates. Add lwgeom_flip_coordinates and
+         ST_FlipCoordinates (#354). Add relevant cunit tests and basic
+         documentation.
+
+2010-02-25 13:30  strk
+
+       * postgis/lwgeom_geos_clean.c: Drop unused code, avoid putting
+         empty geometry in a collection.. [RT-SIGTA]
+
+2010-02-25 13:15  strk
+
+       * postgis/lwgeom_geos_clean.c: Recursively try to build area with
+         portions of the original boundary not on the boundary of newly
+         constructed area and symdifference the new area (if any) with the
+         final polygon being built. This behaviour gives more chance to
+         get a pure areal (not mixed) output still not missing vertices.
+
+2010-02-24 14:40  pramsey
+
+       * liblwgeom/cunit/cu_wkt.c, liblwgeom/lwout_wkt.c: Change
+         dimensionality indicators to have spaces between type indicators
+         for WKT_ISO output form.
+
+2010-02-24 13:50  pramsey
+
+       * liblwgeom/cunit/cu_wkt.c, liblwgeom/liblwgeom.h,
+         liblwgeom/lwgeom.c, liblwgeom/lwout_wkt.c: Add support from SRID=
+         block on EWKT
+
+2010-02-23 22:18  pramsey
+
+       * liblwgeom/cunit/cu_geodetic.c, liblwgeom/cunit/cu_tester.c,
+         liblwgeom/cunit/cu_tester.h: Remove last compile warnings.
+
+2010-02-23 22:16  pramsey
+
+       * liblwgeom/cunit/cu_out_geojson.c, liblwgeom/cunit/cu_out_gml.c,
+         liblwgeom/cunit/cu_out_kml.c, liblwgeom/cunit/cu_out_svg.c:
+         Making test methods static to avoid compiler warnings. For Jeff
+         Adams.
+
+2010-02-23 22:14  pramsey
+
+       * liblwgeom/cunit/cu_algorithm.c, liblwgeom/cunit/cu_geodetic.c,
+         liblwgeom/cunit/cu_homogenize.c, liblwgeom/cunit/cu_libgeom.c,
+         liblwgeom/cunit/cu_measures.c, liblwgeom/cunit/cu_print.c: Making
+         test methods static to avoid compiler warnings.
+
+2010-02-23 22:11  pramsey
+
+       * liblwgeom/cunit/cu_wkt.c: Make test functions static.
+
+2010-02-23 22:07  pramsey
+
+       * liblwgeom/cunit/cu_algorithm.c, liblwgeom/cunit/cu_algorithm.h,
+         liblwgeom/cunit/cu_geodetic.c, liblwgeom/cunit/cu_geodetic.h,
+         liblwgeom/cunit/cu_homogenize.c, liblwgeom/cunit/cu_homogenize.h,
+         liblwgeom/cunit/cu_libgeom.c, liblwgeom/cunit/cu_libgeom.h,
+         liblwgeom/cunit/cu_measures.c, liblwgeom/cunit/cu_measures.h,
+         liblwgeom/cunit/cu_out_geojson.c,
+         liblwgeom/cunit/cu_out_geojson.h, liblwgeom/cunit/cu_out_gml.c,
+         liblwgeom/cunit/cu_out_gml.h, liblwgeom/cunit/cu_out_kml.c,
+         liblwgeom/cunit/cu_out_kml.h, liblwgeom/cunit/cu_out_svg.c,
+         liblwgeom/cunit/cu_out_svg.h, liblwgeom/cunit/cu_print.c,
+         liblwgeom/cunit/cu_print.h, liblwgeom/cunit/cu_tester.c,
+         liblwgeom/cunit/cu_tester.h, liblwgeom/cunit/cu_wkt.c,
+         liblwgeom/cunit/cu_wkt.h: Made unit tests easier to add. New
+         suites now just need to be added to two lines in cu_tester.c, no
+         changes to header files necessary, new tests need one line in the
+         appropriate .c file. From Jeff Adams.
+
+2010-02-23 21:41  pramsey
+
+       * liblwgeom/stringbuffer.c: Remove unused va_copy.
+
+2010-02-23 21:41  pramsey
+
+       * liblwgeom/stringbuffer.h: Woops again, got work and start size
+         values reversed.
+
+2010-02-23 21:30  pramsey
+
+       * liblwgeom/stringbuffer.h: Oops, commit stringbuffer.h with
+         sensible values for internal sizes.
+
+2010-02-23 21:29  pramsey
+
+       * liblwgeom/cunit/cu_wkt.c, liblwgeom/stringbuffer.c,
+         liblwgeom/stringbuffer.h: Improve performance and cut back
+         stringbuffer_t to the minimum.
+
+2010-02-23 19:51  pramsey
+
+       * liblwgeom/cunit/cu_tester.c: Allow cu_tester to accept parameters
+         to run individual tests or suites, from Jeff Adams.
+
+2010-02-23 19:42  strk
+
+       * liblwgeom/ptarray.c, regress/remove_repeated_points.sql,
+         regress/remove_repeated_points_expected: Don't let
+         ST_RemoveRepeatedPoint collapse LINESTRINGs (not sure why, but
+         someone doesn't want them in the db)
+
+2010-02-23 18:29  colivier
+
+       * liblwgeom/liblwgeom.h, liblwgeom/ptarray.c,
+         postgis/lwgeom_in_gml.c: Move ptarray reverse axis function from
+         postgis/lwgeom_in_gml to liblwgeom/ptarray
+
+2010-02-23 18:18  pramsey
+
+       * liblwgeom/cunit/cu_wkt.c: More WKT tests.
+
+2010-02-23 17:55  pramsey
+
+       * liblwgeom/cunit/cu_wkt.c, liblwgeom/cunit/cu_wkt.h: More WKT unit
+         tests
+
+2010-02-23 15:55  colivier
+
+       * liblwgeom/cunit/cu_out_geojson.c, liblwgeom/cunit/cu_out_svg.c:
+         In fact Nested GeometryCollection are never been supported in SVG
+         and GeoJSON. Update the cunit tests cases
+
+2010-02-23 15:21  colivier
+
+       * astyle.sh: Check astyle version prior to do anything. 'blessed'
+         version is 1.23. Related to #433 and postgis-devel discussions
+
+2010-02-23 14:52  colivier
+
+       * postgis/geography_inout.c, regress/Makefile.in,
+         regress/geojson.sql, regress/geojson_expected, regress/gml.sql,
+         regress/gml_expected, regress/kml.sql, regress/kml_expected,
+         regress/out_geography.sql, regress/out_geography_expected,
+         regress/out_geometry.sql, regress/out_geometry_expected,
+         regress/svg.sql, regress/svg_expected: Fix 443. Move all regress
+         export functions test files in a single one. add geography output
+         regression tests (SVG/KML/GML/GeoJSON)
+
+2010-02-22 22:43  pramsey
+
+       * liblwgeom/cunit/cu_wkt.c: Add more unit tests for WKT
+
+2010-02-22 22:04  colivier
+
+       * liblwgeom/cunit/cu_out_geojson.c, liblwgeom/lwout_geojson.c: Fix
+         #441. And introduce a change in behaviour: if geometryCollection
+         and bbox, not sub geoms bbox are provided anymore
+
+2010-02-22 20:58  strk
+
+       * postgis/lwgeom_geos_clean.c, postgis/postgis.sql.in.c: Let
+         ST_CleanGeometry down to C [RT-SIGTA]
+
+2010-02-22 20:45  strk
+
+       * postgis/lwgeom_geos_clean.c: Derive an lwgeom_make_valid from
+         ST_MakeValid [RT-SIGTA]
+
+2010-02-22 20:42  pramsey
+
+       * doc/reference_output.xml, liblwgeom/Makefile.in,
+         liblwgeom/cunit/Makefile.in, liblwgeom/cunit/cu_print.c,
+         liblwgeom/cunit/cu_print.h, liblwgeom/cunit/cu_tester.c,
+         liblwgeom/cunit/cu_tester.h, liblwgeom/liblwgeom.h,
+         liblwgeom/lwprint.c, postgis/lwgeom_inout.c,
+         postgis/postgis.sql.in.c: ST_AsLatLonText(geometry, format) from
+         Jeff Adams
+
+2010-02-22 20:29  strk
+
+       * postgis/lwgeom_geos_clean.c, postgis/postgis.sql.in.c: Follow
+         style guidelines for function naming
+
+2010-02-22 19:53  pramsey
+
+       * liblwgeom/Makefile.in, liblwgeom/cunit/Makefile.in,
+         liblwgeom/cunit/cu_tester.c, liblwgeom/cunit/cu_tester.h,
+         liblwgeom/cunit/cu_wkt.c, liblwgeom/cunit/cu_wkt.h,
+         liblwgeom/libgeom.h, liblwgeom/liblwgeom.h,
+         liblwgeom/lwout_wkt.c, liblwgeom/stringbuffer.c,
+         liblwgeom/stringbuffer.h: First cut of new WKT output functions,
+         need more unit tests.
+
+2010-02-22 19:52  colivier
+
+       * liblwgeom/lwout_svg.c, postgis/geography_inout.c,
+         postgis/lwgeom_export.c, postgis/lwgeom_export.h: Fix missing
+         math.h include in lwout_svg (#438). Put back lwgeom_export.h as
+         we need header for getSRSbySRID.
+
+2010-02-22 19:37  strk
+
+       * liblwgeom/liblwgeom.h: Oops (#434)
+
+2010-02-22 19:35  strk
+
+       * postgis/lwgeom_geos_clean.c: Fix warnings when building with GEOS
+         < 3.3.0 (ticket #434
+
+2010-02-22 19:31  strk
+
+       * install-sh, liblwgeom/liblwgeom.h: Fix missing prototypes
+         warnings
+
+2010-02-22 19:31  colivier
+
+       * liblwgeom/lwout_geojson.c, liblwgeom/lwout_gml.c,
+         liblwgeom/lwout_kml.c, liblwgeom/lwout_svg.c: Id tag
+
+2010-02-22 19:16  colivier
+
+       * postgis/Makefile.in, postgis/geography_inout.c,
+         postgis/lwgeom_export.c, postgis/lwgeom_export.h,
+         postgis/lwgeom_geojson.c, postgis/lwgeom_gml.c,
+         postgis/lwgeom_kml.c, postgis/lwgeom_svg.c,
+         postgis/postgis.sql.in.c: merge all export functions in a same
+         file. remove useless old ones. rename SVG one to LWGEOM_asSVG for
+         consistancy.
+
+2010-02-22 18:49  colivier
+
+       * liblwgeom/cunit/cu_out_geojson.c, liblwgeom/cunit/cu_out_gml.c,
+         liblwgeom/cunit/cu_out_kml.c: Fix comment stuff in cunit
+
+2010-02-22 18:43  colivier
+
+       * liblwgeom/Makefile.in, liblwgeom/cunit/Makefile.in,
+         liblwgeom/cunit/cu_out_svg.c, liblwgeom/cunit/cu_out_svg.h,
+         liblwgeom/cunit/cu_tester.c, liblwgeom/cunit/cu_tester.h,
+         liblwgeom/liblwgeom.h, liblwgeom/lwout_svg.c,
+         postgis/geography_inout.c, postgis/lwgeom_export.h,
+         postgis/lwgeom_svg.c, regress/svg.sql, regress/svg_expected: move
+         ST_AsSVG from postgis to lwgeom dir. write cun it tests. related
+         to #377
+
+2010-02-22 15:37  colivier
+
+       * liblwgeom/cunit/cu_out_geojson.c: bbox only bother about external
+         ring. add the related cunit test
+
+2010-02-22 15:30  pramsey
+
+       * liblwgeom/Makefile.in, liblwgeom/liblwgeom.h,
+         liblwgeom/stringbuffer.c, liblwgeom/stringbuffer.h,
+         loader/Makefile.in, loader/shp2pgsql-core.h,
+         loader/stringbuffer.c, loader/stringbuffer.h: Move stringbuffer
+         from ./loader to ./liblwgeom for use in string emitter functions.
+
+2010-02-22 14:03  colivier
+
+       * liblwgeom/Makefile.in, liblwgeom/cunit/Makefile.in,
+         liblwgeom/cunit/cu_out_geojson.c,
+         liblwgeom/cunit/cu_out_geojson.h, liblwgeom/cunit/cu_tester.c,
+         liblwgeom/cunit/cu_tester.h, liblwgeom/liblwgeom.h,
+         liblwgeom/lwout_geojson.c, postgis/geography_inout.c,
+         postgis/lwgeom_geojson.c, regress/geojson.sql,
+         regress/geojson_expected: Move ST_AsGeoJson from postgis to
+         liblwgeom dir. Use as most as cunit test as possible. Related to
+         #377.
+
+2010-02-21 22:34  strk
+
+       * postgis/postgis.sql.in.c: Cleanup the GeometryClean function now
+         that vertex checking is done better in ST_MakeValid
+
+2010-02-21 22:10  strk
+
+       * postgis/lwgeom_geos_clean.c: Force multi-type in output if input
+         was multi [RT-SIGTA]
+
+2010-02-21 21:53  colivier
+
+       * liblwgeom/cunit/cu_out_gml.c, liblwgeom/cunit/cu_out_kml.c: Add
+         missing MultiPoint test. Fix wrong LWGEOM type on cu_gml tests.
+
+2010-02-21 21:34  colivier
+
+       * liblwgeom/cunit/cu_homogenize.c: add explicit void return type
+
+2010-02-21 21:11  strk
+
+       * postgis/Makefile.in, postgis/lwgeom_geos.c,
+         postgis/lwgeom_geos.h, postgis/lwgeom_geos_clean.c,
+         regress/Makefile.in: Disable 'clean' test (still deciding on
+         what's the expected output); keep only cut-lines that have
+         vertices not shared with boundary of final area; move 'clean'
+         code in separate file [RT-SIGTA].
+
+2010-02-21 20:32  colivier
+
+       * liblwgeom/Makefile.in, liblwgeom/cunit/Makefile.in,
+         liblwgeom/cunit/cu_out_gml.c, liblwgeom/cunit/cu_out_gml.h,
+         liblwgeom/cunit/cu_out_kml.c, liblwgeom/cunit/cu_out_kml.h,
+         liblwgeom/cunit/cu_tester.c, liblwgeom/cunit/cu_tester.h,
+         liblwgeom/liblwgeom.h, liblwgeom/lwout_gml.c,
+         liblwgeom/lwout_kml.c, postgis/geography_inout.c,
+         postgis/lwgeom_kml.c, regress/kml.sql, regress/kml_expected: Move
+         ST_AsKML from postgis to liblwgeom dir. Use as most cunit test as
+         possible. Few related corrections on GML similar implementation.
+         cf #377
+
+2010-02-21 18:23  colivier
+
+       * liblwgeom/lwout_gml.c: Add forgotten lwout_gml.c file (#377)
+
+2010-02-21 18:18  colivier
+
+       * liblwgeom/Makefile.in, liblwgeom/cunit/Makefile.in,
+         liblwgeom/cunit/cu_tester.c, liblwgeom/cunit/cu_tester.h,
+         liblwgeom/liblwgeom.h, postgis/geography_inout.c,
+         postgis/lwgeom_export.h, postgis/lwgeom_gml.c, regress/gml.sql,
+         regress/gml_expected, regress/tickets_expected: Move ST_AsGML
+         from postgis dir to liblwgeom. Rewrite most units test with
+         cunit. cf #377
+
+2010-02-21 12:36  colivier
+
+       * extras/wkb_reader/readwkb.c, liblwgeom/g_ptarray.c,
+         liblwgeom/lwalgorithm.c, liblwgeom/lwgeom_api.c,
+         liblwgeom/lwgunparse.c, liblwgeom/lwsegmentize.c,
+         liblwgeom/lwspheroid.c, postgis/geography_inout.c,
+         postgis/lwgeom_gist.c, postgis/lwgeom_in_gml.c,
+         postgis/lwgeom_in_kml.c, postgis/lwgeom_inout.c,
+         postgis/lwgeom_ogc.c: make astyle session
+
+2010-02-21 12:22  strk
+
+       * NEWS, doc/reference_processing.xml, liblwgeom/liblwgeom.h,
+         liblwgeom/lwcollection.c, liblwgeom/lwgeom.c, liblwgeom/lwline.c,
+         liblwgeom/lwmpoint.c, liblwgeom/lwpoly.c, liblwgeom/ptarray.c,
+         postgis/lwgeom_functions_basic.c, postgis/postgis.sql.in.c,
+         regress/Makefile.in, regress/remove_repeated_points.sql,
+         regress/remove_repeated_points_expected: ST_RemoveRepeatedPoints
+         [RT-SIGTA]
+
+2010-02-21 12:21  strk
+
+       * postgis/lwgeom_functions_analytic.c: style...
+
+2010-02-21 12:21  strk
+
+       * liblwgeom/cunit/cu_homogenize.c, liblwgeom/cunit/cu_tester.c,
+         liblwgeom/lwhomogenize.c, postgis/lwgeom_gml.c,
+         postgis/lwgeom_in_kml.c: Make stylish
+
+2010-02-20 19:47  colivier
+
+       * liblwgeom/cunit/cu_homogenize.c: use the rights homogenize cunit
+         suite handlers
+
+2010-02-20 19:09  colivier
+
+       * postgis/lwgeom_gml.c: Fix computed string length in Polygon with
+         several rings for ST_AsGML with GML3. Related to #421
+
+2010-02-20 18:26  colivier
+
+       * postgis/lwgeom_in_kml.c, regress/in_kml.sql,
+         regress/in_kml_expected: Use lwgeom_homogenize in in_kml stuff.
+         Related to #375
+
+2010-02-20 18:25  colivier
+
+       * liblwgeom/Makefile.in, liblwgeom/cunit/Makefile.in,
+         liblwgeom/cunit/cu_homogenize.c, liblwgeom/cunit/cu_homogenize.h,
+         liblwgeom/cunit/cu_tester.c, liblwgeom/cunit/cu_tester.h,
+         liblwgeom/liblwgeom.h, liblwgeom/lwcollection.c,
+         liblwgeom/lwhomogenize.c, liblwgeom/lwhomogenize.h: Add
+         lwgeom_homogenize function. Related to #375. Add cunit related
+         tests
+
+2010-02-20 16:47  colivier
+
+       * liblwgeom/cunit/cu_tester.c, liblwgeom/cunit/cu_tester.h: Add
+         Cunit - lwerror use case handle - #420
+
+2010-02-18 21:02  pramsey
+
+       * postgis/lwgeom_functions_analytic.c: Add multilinestring support
+         to st_line_substring (#419)
+
+2010-02-17 21:02  strk
+
+       * postgis/lwgeom_geos.c, regress/clean.sql, regress/clean_expected:
+         Allow retaining badly collapsed rings (single-point) as points in
+         ST_MakeValid. Add testcase for it [RT-SIGTA]
+
+2010-02-16 23:27  kneufeld
+
+       * doc/reference_editor.xml: removed sfs_compliant note for
+         ST_Transform
+
+2010-02-16 09:38  strk
+
+       * doc/reference_accessor.xml, postgis/lwgeom_geos.c: Return NULL
+         rather than throwing when a COLLECTION is given to ST_Boundary
+         [RT-SIGTA]
+
+2010-02-16 09:29  strk
+
+       * postgis/lwgeom_geos.c: Fix build with --enable-debug=3 [RT-SIGTA]
+
+2010-02-16 09:08  strk
+
+       * regress/clean.sql: Add origin field for the clean dataset table,
+         so we can add PG-specific ones w/out caring about visualizing
+         them:)
+
+2010-02-16 09:06  strk
+
+       * regress/clean.sql, regress/clean_expected: Add a test for input
+         being invalid (a test of the test)
+
+2010-02-16 09:03  strk
+
+       * postgis/lwgeom_geos.c: Separate areal-specific cleanups in
+         LWGEOM_GEOS_makeValidPolygon [RT-SIGTA]
+
+2010-02-16 08:28  strk
+
+       * postgis/postgis.sql.in.c: Empty geometries are cleanest
+         [RT-SIGTA]
+
+2010-02-16 08:22  strk
+
+       * postgis/postgis.sql.in.c: Drop the optional arg to ST_MakeClean,
+         document what it does, improve the ST_CleanGeometry stub.
+         [RT-SIGTA]
+
+2010-02-16 08:07  strk
+
+       * postgis/lwgeom_geos.c, regress/clean.sql: Drop the optional
+         parameter to ST_MakeValid, we always want to collect collapses
+         (users can always filter later) [RT-SIGTA].
+
+2010-02-16 08:03  strk
+
+       * doc/reference_accessor.xml: Document ST_Dimension handling of
+         empty geometries
+
+2010-02-16 07:54  strk
+
+       * postgis/lwgeom_ogc.c: Do not throw exception on empty
+         ST_Dimension(empty) [RT-SIGTA]
+
+2010-02-15 22:41  strk
+
+       * postgis/lwgeom_geos.c: Further cleanups in ST_MakeClean
+         [RT-SIGTA]
+
+2010-02-15 22:31  strk
+
+       * postgis/lwgeom_geos.c: Fix unsupported message
+
+2010-02-15 21:17  strk
+
+       * postgis/lwgeom_geos.c: Plug more leaks
+
+2010-02-15 20:40  strk
+
+       * postgis/lwgeom_geos.c: Plug memory leak on GEOS geom construction
+         failure [RT-SIGTA]
+
+2010-02-15 20:21  strk
+
+       * regress/clean.sql, regress/clean_expected: Rework the regress
+         test to make it easier for curious people to keep the test
+         dataset for inspection with some GUI (give it a try, it's a nice
+         one).
+
+2010-02-14 23:35  strk
+
+       * doc/using_postgis_dataman.xml: Clarify the case of linestring
+         invalidity dropping confugins reference to linearrings
+
+2010-02-14 22:59  strk
+
+       * postgis/lwgeom_geos.c, postgis/postgis.sql.in.c,
+         regress/Makefile.in, regress/clean.sql, regress/clean_expected:
+         Implement ST_MakeValid(geom_in, collect_collapses) and stub
+         ST_CleanGeometry. Add regression test for ST_MakeValid and
+         polygons [RT-SIGTA]
+
+2010-02-14 16:54  strk
+
+       * postgis/lwgeom_dump.c: Cleanups. Hope to reuse some structs for a
+         C-version of ST_DumpPoints
+
+2010-02-14 16:33  strk
+
+       * doc/reference_processing.xml: Try to make st_DumpPoints reference
+         somewhat clearer [RT-SIGTA]
+
+2010-02-14 13:46  strk
+
+       * liblwgeom/liblwgeom.h, liblwgeom/ptarray.c:
+         ptarray_remove_repeated_points [RT-SIGTA]
+
+2010-02-13 15:29  strk
+
+       * regress/tickets.sql, regress/tickets_expected: Add another
+         validity test [RT-SIGTA]
+
+2010-02-13 14:35  strk
+
+       * GNUmakefile, postgis/lwgeom_geos.c: Handle NULL returns from
+         POSTGIS2GEOS and LWGEOM2GEOS now that we allow that [RT-SIGTA].
+         Add a 'commit' rule (give it a try)
+
+2010-02-12 23:04  strk
+
+       * postgis/lwgeom_geos.c: Revert GEOS error handlers to be lwnotice
+         to avoid aborting full transactions (like it was in 1.5)
+
+2010-02-11 23:12  strk
+
+       * doc/reference_measure.xml: Fix typo
+
+2010-02-11 21:01  strk
+
+       * liblwgeom/ptarray.c: Get style
+
+2010-02-11 18:56  strk
+
+       * postgis/lwgeom_geos.c, postgis/lwgeom_geos.h: Separate GEOS part
+         of 'buildarea' function from POSTGIS part of it (might eventually
+         be moved down to GEOS) [RT-SIGTA]
+
+2010-02-10 22:23  strk
+
+       * doc/reference_lrs.xml: xref
+
+2010-02-10 20:54  strk
+
+       * liblwgeom/ptarray.c: Enhance documentation of ptarray_addPoint
+         [RT-SIGTA]
+
+2010-02-09 22:36  strk
+
+       * postgis/lwgeom_inout.c: Don't refuse to output invalid geometries
+         trough a cursor, being consistent with other output routines
+         (dumper ends up using these) -- [RT-SIGTA]
+
+2010-02-09 17:59  strk
+
+       * liblwgeom/liblwgeom.h: Oops, it seems I broke the build (sorry)
+
+2010-02-09 06:52  strk
+
+       * liblwgeom/ptarray.c: Fix documention
+
+2010-02-08 22:36  strk
+
+       * NEWS: tweak the sponsor name
+
+2010-02-08 21:39  strk
+
+       * postgis/lwgeom_geos.c: Initialie GEOS using lwerror for errors so
+         that exceptions are really handled (or testcases in #411 crash on
+         many GEOS functions)
+
+2010-02-08 20:05  strk
+
+       * NEWS: Add credits to new feature item
+
+2010-02-08 18:54  strk
+
+       * postgis/lwgeom_inout.c, postgis/lwgeom_ogc.c,
+         regress/tickets.sql, regress/tickets_expected: Don't refuse to
+         unparse malformed geometries. Fixes #411. Didn't seem to expose
+         the crash in #168, the testcase for it was expanded to extract
+         invalidity reason.
+
+2010-02-06 13:57  strk
+
+       * postgis/lwgeom_geos.c: Simplify hooks on GEOS error reporter
+         function from isvalid* functions
+
+2010-02-06 13:48  strk
+
+       * regress/tickets.sql, regress/tickets_expected: Add another test
+         for #407
+
+2010-02-06 10:49  colivier
+
+       * postgis/lwgeom_svg.c, regress/svg.sql, regress/svg_expected: Fix
+         non NULL terminated string in ST_AsSVG with GEOMETRYCOLLECTION
+         EMPTY, cf #409 reported by sdikiy. Add related unit test
+
+2010-02-05 20:58  strk
+
+       * NEWS: Add ST_isValidDetail item
+
+2010-02-05 20:55  strk
+
+       * postgis/lwgeom_geos.c, regress/tickets.sql,
+         regress/tickets_expected: Register a buffer-logger as
+         error-reporter from ST_isValidReason and ST_isValidDetail so to
+         catch exceptions thrown by GEOS at postgis->geos conversion for
+         the sake of reporting actual error. Fixes ticket #408. Completed
+         with testcase.
+
+2010-02-05 17:58  strk
+
+       * doc/reference_processing.xml: A space after return type looks
+         better (and seems to be the policy) for funcdef tags
+
+2010-02-05 17:57  strk
+
+       * doc/reference_accessor.xml: Document ST_IsValidDetail
+
+2010-02-05 17:26  strk
+
+       * postgis/lwgeom_geos.c, postgis/postgis.sql.in.c: Add
+         ST_isValidDetail(geom) returns valid_detail (new type!)
+
+2010-02-04 20:30  strk
+
+       * postgis/geography_gist.c: Astyle run (a-ha, got you!)
+
+2010-02-04 17:43  pramsey
+
+       * NEWS, README.postgis, Version.config: Push version numbers on
+         trunk forward to next release.
+
+2010-02-04 17:21  pramsey
+
+       * ChangeLog, NEWS, README.postgis, doc/release_notes.xml: Update
+         release dates and changelog for 1.5.0
+
 2010-02-03 22:42  pramsey
 
        * loader/shp2pgsql-core.c: Initialize config->createindex value to
index a4ce8093cf6aca87bf5813e49eadffe8e30b0f8e..cd5734b0f1ac1916e92671504164f3135b03a328 100644 (file)
@@ -139,7 +139,7 @@ static size_t gserialized_from_any_size(const LWGEOM *geom)
 {
        int type = TYPE_GETTYPE(geom->type);
 
-       LWDEBUGF(2, "Input type: %s", lwgeom_typename(type));
+       LWDEBUGF(2, "Input type: %s", lwtype_name(type));
 
        switch (type)
        {
@@ -389,7 +389,7 @@ static size_t gserialized_from_lwgeom_any(const LWGEOM *geom, uchar *buf)
 
        type = TYPE_GETTYPE(geom->type);
 
-       LWDEBUGF(2, "Input type (%d) %s", type, lwgeom_typename(type));
+       LWDEBUGF(2, "Input type (%d) %s", type, lwtype_name(type));
        LWDEBUGF(2, "LWGEOM(%p) uchar(%p)", geom, buf);
 
        switch (type)
@@ -428,29 +428,29 @@ static size_t gserialized_from_gbox(const GBOX *gbox, uchar *buf)
 
        loc = buf;
 
-       f = nextDown_f(gbox->xmin);
+       f = next_float_down(gbox->xmin);
        memcpy(loc, &f, sizeof(float));
        loc += sizeof(float);
 
-       f = nextUp_f(gbox->xmax);
+       f = next_float_up(gbox->xmax);
        memcpy(loc, &f, sizeof(float));
        loc += sizeof(float);
 
-       f = nextDown_f(gbox->ymin);
+       f = next_float_down(gbox->ymin);
        memcpy(loc, &f, sizeof(float));
        loc += sizeof(float);
 
-       f = nextUp_f(gbox->ymax);
+       f = next_float_up(gbox->ymax);
        memcpy(loc, &f, sizeof(float));
        loc += sizeof(float);
 
        if ( FLAGS_GET_GEODETIC(gbox->flags) )
        {
-               f = nextDown_f(gbox->zmin);
+               f = next_float_down(gbox->zmin);
                memcpy(loc, &f, sizeof(float));
                loc += sizeof(float);
 
-               f = nextUp_f(gbox->zmax);
+               f = next_float_up(gbox->zmax);
                memcpy(loc, &f, sizeof(float));
                loc += sizeof(float);
 
@@ -461,11 +461,11 @@ static size_t gserialized_from_gbox(const GBOX *gbox, uchar *buf)
 
        if ( FLAGS_GET_Z(gbox->flags) )
        {
-               f = nextDown_f(gbox->zmin);
+               f = next_float_down(gbox->zmin);
                memcpy(loc, &f, sizeof(float));
                loc += sizeof(float);
 
-               f = nextUp_f(gbox->zmax);
+               f = next_float_up(gbox->zmax);
                memcpy(loc, &f, sizeof(float));
                loc += sizeof(float);
 
@@ -473,11 +473,11 @@ static size_t gserialized_from_gbox(const GBOX *gbox, uchar *buf)
 
        if ( FLAGS_GET_M(gbox->flags) )
        {
-               f = nextDown_f(gbox->mmin);
+               f = next_float_down(gbox->mmin);
                memcpy(loc, &f, sizeof(float));
                loc += sizeof(float);
 
-               f = nextUp_f(gbox->mmax);
+               f = next_float_up(gbox->mmax);
                memcpy(loc, &f, sizeof(float));
                loc += sizeof(float);
        }
@@ -782,7 +782,7 @@ static LWCOLLECTION* lwcollection_from_gserialized_buffer(uchar *data_ptr, uchar
 
                if ( ! lwcollection_from_gserialized_allowed_types(type, subtype) )
                {
-                       lwerror("Invalid subtype (%s) for collection type (%s)", lwgeom_typename(subtype), lwgeom_typename(type));
+                       lwerror("Invalid subtype (%s) for collection type (%s)", lwtype_name(subtype), lwtype_name(type));
                        lwfree(collection);
                        return NULL;
                }
@@ -805,7 +805,7 @@ LWGEOM* lwgeom_from_gserialized_buffer(uchar *data_ptr, uchar g_flags, size_t *g
 
        type = lw_get_uint32(data_ptr);
 
-       LWDEBUGF(2, "Got type %d (%s)", type, lwgeom_typename(type));
+       LWDEBUGF(2, "Got type %d (%s)", type, lwtype_name(type));
 
        switch (type)
        {
@@ -1065,7 +1065,7 @@ static int gserialized_calculate_gbox_geocentric_from_any(uchar *data_ptr, size_
 
        type = lw_get_uint32(data_ptr);
 
-       LWDEBUGF(2, "Got type %d (%s)", type, lwgeom_typename(type));
+       LWDEBUGF(2, "Got type %d (%s)", type, lwtype_name(type));
        LWDEBUGF(3, "Got gbox pointer (%p)", gbox);
 
        switch (type)
index f86842f9024ba585fb50199bbb945e2a73003639..6ff457a5e4d0401de2b4db81ba4b181e9bb4d469 100644 (file)
@@ -66,7 +66,7 @@ struct geomtype_struct geomtype_struct_array[32] =
 
 uchar gflags(int hasz, int hasm, int geodetic)
 {
-       unsigned char flags = 0;
+       uchar flags = 0;
        if ( hasz )
                FLAGS_SET_Z(flags, 1);
        if ( hasm )
index fd2b07497f6848d2249ff63fdfccbd70867c662d..25a27eb3e5f183e247c3af2276c1e6a8beb6e6ad 100644 (file)
 #define WKB_HEX 0x10
 #define WKB_NO_NPOINTS 0x20 /* Internal use only */
 
+#define WKB_DOUBLE_SIZE 8 /* Internal use only */
+#define WKB_INT_SIZE 4 /* Internal use only */
+#define WKB_BYTE_SIZE 1 /* Internal use only */
+
 /**
 * Maximum allowed SRID value. 
 * Currently we are using 20 bits (1048575) of storage for SRID.
index 7f097e201511f630ea3a1757598e3307bd502923..1c779225ef2d4ddb2d18c54dc00a05601f39c151 100644 (file)
 #define MAXFLOAT      3.402823466e+38F
 #endif
 
-#ifndef C_H
+typedef unsigned char uchar;
 
+#ifndef C_H
 typedef unsigned int uint32;
 typedef int int32;
-
 #endif
 
 /**
@@ -175,7 +175,6 @@ va_dcl
 
 /******************************************************************/
 
-typedef unsigned char uchar;
 
 typedef struct
 {
@@ -319,7 +318,8 @@ typedef struct
        /* use TYPE_* macros to handle */
        uchar  dims;
 
-       uint32 npoints;
+       int npoints;
+       int maxpoints;
 }
 POINTARRAY;
 
@@ -386,7 +386,7 @@ typedef struct
        uchar type; /* LINETYPE */
        BOX2DFLOAT4 *bbox;
        uint32 SRID;
-       POINTARRAY    *points; /* array of POINT3D */
+       POINTARRAY *points; /* array of POINT3D */
 }
 LWLINE; /* "light-weight line" */
 
@@ -396,7 +396,8 @@ typedef struct
        uchar type; /* POLYGONTYPE */
        BOX2DFLOAT4 *bbox;
        uint32 SRID;
-       int  nrings;
+       int nrings;
+       int maxrings;
        POINTARRAY **rings; /* list of rings (list of points) */
 }
 LWPOLY; /* "light-weight polygon" */
@@ -407,7 +408,8 @@ typedef struct
        uchar type;
        BOX2DFLOAT4 *bbox;
        uint32 SRID;
-       int  ngeoms;
+       int ngeoms;
+       int maxgeoms;
        LWPOINT **geoms;
 }
 LWMPOINT;
@@ -418,7 +420,8 @@ typedef struct
        uchar type;
        BOX2DFLOAT4 *bbox;
        uint32 SRID;
-       int  ngeoms;
+       int ngeoms;
+       int maxgeoms;
        LWLINE **geoms;
 }
 LWMLINE;
@@ -429,7 +432,8 @@ typedef struct
        uchar type;
        BOX2DFLOAT4 *bbox;
        uint32 SRID;
-       int  ngeoms;
+       int ngeoms;
+       int maxgeoms;
        LWPOLY **geoms;
 }
 LWMPOLY;
@@ -440,7 +444,8 @@ typedef struct
        uchar type;
        BOX2DFLOAT4 *bbox;
        uint32 SRID;
-       int  ngeoms;
+       int ngeoms;
+       int maxgeoms;
        LWGEOM **geoms;
 }
 LWCOLLECTION;
@@ -462,6 +467,7 @@ typedef struct
        BOX2DFLOAT4 *bbox;
        uint32 SRID;
        int ngeoms;
+       int maxgeoms;
        LWGEOM **geoms;
 }
 LWCOMPOUND; /* "light-weight compound line" */
@@ -473,6 +479,7 @@ typedef struct
        BOX2DFLOAT4 *bbox;
        uint32 SRID;
        int nrings;
+       int maxrings;
        LWGEOM **rings; /* list of rings (list of points) */
 }
 LWCURVEPOLY; /* "light-weight polygon" */
@@ -484,6 +491,7 @@ typedef struct
        BOX2DFLOAT4 *bbox;
        uint32 SRID;
        int ngeoms;
+       int maxgeoms;
        LWGEOM **geoms;
 }
 LWMCURVE;
@@ -495,30 +503,37 @@ typedef struct
        BOX2DFLOAT4 *bbox;
        uint32 SRID;
        int ngeoms;
+       int maxgeoms;
        LWGEOM **geoms;
 }
 LWMSURFACE;
 
 /* Casts LWGEOM->LW* (return NULL if cast is illegal) */
-extern LWMPOLY *lwgeom_as_lwmpoly(LWGEOM *lwgeom);
-extern LWMLINE *lwgeom_as_lwmline(LWGEOM *lwgeom);
-extern LWMPOINT *lwgeom_as_lwmpoint(LWGEOM *lwgeom);
-extern LWCOLLECTION *lwgeom_as_lwcollection(LWGEOM *lwgeom);
-extern LWPOLY *lwgeom_as_lwpoly(LWGEOM *lwgeom);
-extern LWLINE *lwgeom_as_lwline(LWGEOM *lwgeom);
-extern LWPOINT *lwgeom_as_lwpoint(LWGEOM *lwgeom);
-extern LWCIRCSTRING *lwgeom_as_lwcircstring(LWGEOM *lwgeom);
-extern LWGEOM *lwgeom_as_multi(LWGEOM *lwgeom);
+extern LWMPOLY *lwgeom_as_lwmpoly(const LWGEOM *lwgeom);
+extern LWMLINE *lwgeom_as_lwmline(const LWGEOM *lwgeom);
+extern LWMPOINT *lwgeom_as_lwmpoint(const LWGEOM *lwgeom);
+extern LWCOLLECTION *lwgeom_as_lwcollection(const LWGEOM *lwgeom);
+extern LWPOLY *lwgeom_as_lwpoly(const LWGEOM *lwgeom);
+extern LWLINE *lwgeom_as_lwline(const LWGEOM *lwgeom);
+extern LWPOINT *lwgeom_as_lwpoint(const LWGEOM *lwgeom);
+extern LWCIRCSTRING *lwgeom_as_lwcircstring(const LWGEOM *lwgeom);
+extern LWGEOM *lwgeom_as_multi(const LWGEOM *lwgeom);
 
 /* Casts LW*->LWGEOM (always cast) */
-extern LWGEOM *lwmpoly_as_lwgeom(LWMPOLY *obj);
-extern LWGEOM *lwmline_as_lwgeom(LWMLINE *obj);
-extern LWGEOM *lwmpoint_as_lwgeom(LWMPOINT *obj);
-extern LWGEOM *lwcollection_as_lwgeom(LWCOLLECTION *obj);
-extern LWGEOM *lwcircstring_as_lwgeom(LWCIRCSTRING *obj);
-extern LWGEOM *lwpoly_as_lwgeom(LWPOLY *obj);
-extern LWGEOM *lwline_as_lwgeom(LWLINE *obj);
-extern LWGEOM *lwpoint_as_lwgeom(LWPOINT *obj);
+extern LWGEOM *lwmpoly_as_lwgeom(const LWMPOLY *obj);
+extern LWGEOM *lwmline_as_lwgeom(const LWMLINE *obj);
+extern LWGEOM *lwmpoint_as_lwgeom(const LWMPOINT *obj);
+extern LWGEOM *lwcollection_as_lwgeom(const LWCOLLECTION *obj);
+extern LWGEOM *lwcircstring_as_lwgeom(const LWCIRCSTRING *obj);
+extern LWGEOM *lwpoly_as_lwgeom(const LWPOLY *obj);
+extern LWGEOM *lwline_as_lwgeom(const LWLINE *obj);
+extern LWGEOM *lwpoint_as_lwgeom(const LWPOINT *obj);
+
+
+extern LWCOLLECTION* lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom);
+extern LWMPOINT* lwmpoint_add_lwpoint(LWMPOINT *mobj, const LWPOINT *obj);
+extern LWMLINE* lwmline_add_lwline(LWMLINE *mobj, const LWLINE *obj);
+extern LWMPOLY* lwmpoly_add_lwpoly(LWMPOLY *mobj, const LWPOLY *obj);
 
 /*
  * Call this function everytime LWGEOM coordinates
@@ -660,7 +675,6 @@ extern int pointArray_ptsize(const POINTARRAY *pa);
 #define WKBSRIDFLAG 0x20000000
 #define WKBBBOXFLAG 0x10000000
 
-
 /* These macros work on PG_LWGEOM.type, LWGEOM.type and all its subclasses */
 
 #define TYPE_SETTYPE(c,t) ((c)=(((c)&0xF0)|(t)))
@@ -713,8 +727,7 @@ PG_LWGEOM;
  * If you request bbox (wantbbox=1) it will be extracted or computed
  * from the serialized form.
  */
-extern PG_LWGEOM *PG_LWGEOM_construct(uchar *serialized, int SRID,
-                                      int wantbbox);
+extern PG_LWGEOM *PG_LWGEOM_construct(uchar *serialized, int SRID, int wantbbox);
 
 /*
  * Compute bbox of serialized geom
@@ -877,7 +890,7 @@ extern void lwcircstring_serialize_buf(LWCIRCSTRING *curve, uchar *buf, size_t *
 /*
  * find bounding box (standard one)  zmin=zmax=0 if 2d (might change to NaN)
  */
-extern BOX3D *lwcircstring_compute_box3d(LWCIRCSTRING *curve);
+extern BOX3D *lwcircstring_compute_box3d(const LWCIRCSTRING *curve);
 
 
 
@@ -1179,12 +1192,10 @@ extern float LWGEOM_Maxf(float a, float b);
 extern double LWGEOM_Mind(double a, double b);
 extern double LWGEOM_Maxd(double a, double b);
 
-extern float  nextDown_f(double d);
-extern float  nextUp_f(double d);
-extern double nextDown_d(float d);
-extern double nextUp_d(float d);
-
-extern float nextafterf_custom(float x, float y);
+extern float  next_float_down(double d);
+extern float  next_float_up(double d);
+extern double next_double_down(float d);
+extern double next_double_up(float d);
 
 
 #define LW_MAX(a,b) ((a) >     (b) ? (a) : (b))
@@ -1196,26 +1207,26 @@ extern float nextafterf_custom(float x, float y);
 #define DIST2D_MIN             1
 
 /* general utilities */
-extern double distance2d_pt_pt(POINT2D *p1, POINT2D *p2);
-extern double distance2d_pt_seg(POINT2D *p, POINT2D *A, POINT2D *B);
+extern double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2);
+extern double distance2d_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B);
 extern LWGEOM *lw_dist2d_distancepoint(uchar *lw1, uchar *lw2,int srid,int mode);
 extern LWGEOM *lw_dist2d_distanceline(uchar *lw1, uchar *lw2,int srid,int mode);
 extern double lwgeom_mindistance2d(uchar *lw1, uchar *lw2);
 extern double lwgeom_mindistance2d_tolerance(uchar *lw1, uchar *lw2, double tolerance);
 extern double lwgeom_maxdistance2d(uchar *lw1, uchar *lw2);
 extern double lwgeom_maxdistance2d_tolerance(uchar *lw1, uchar *lw2, double tolerance);
-extern double lwgeom_polygon_area(LWPOLY *poly);
-extern double lwgeom_polygon_perimeter(LWPOLY *poly);
-extern double lwgeom_polygon_perimeter2d(LWPOLY *poly);
-extern double lwgeom_pointarray_length2d(POINTARRAY *pts);
-extern double lwgeom_pointarray_length(POINTARRAY *pts);
+extern double lwgeom_polygon_area(const LWPOLY *poly);
+extern double lwgeom_polygon_perimeter(const LWPOLY *poly);
+extern double lwgeom_polygon_perimeter2d(const LWPOLY *poly);
+extern double lwgeom_pointarray_length2d(const POINTARRAY *pts);
+extern double lwgeom_pointarray_length(const POINTARRAY *pts);
 extern void lwgeom_force2d_recursive(uchar *serialized, uchar *optr, size_t *retsize);
 extern void lwgeom_force3dz_recursive(uchar *serialized, uchar *optr, size_t *retsize);
 extern void lwgeom_force3dm_recursive(uchar *serialized, uchar *optr, size_t *retsize);
 extern void lwgeom_force4d_recursive(uchar *serialized, uchar *optr, size_t *retsize);
-extern int pt_in_ring_2d(POINT2D *p, POINTARRAY *ring);
-extern int pt_in_poly_2d(POINT2D *p, LWPOLY *poly);
-extern int azimuth_pt_pt(POINT2D *p1, POINT2D *p2, double *ret);
+extern int pt_in_ring_2d(const POINT2D *p, const POINTARRAY *ring);
+extern int pt_in_poly_2d(const POINT2D *p, const LWPOLY *poly);
+extern int azimuth_pt_pt(const POINT2D *p1, const POINT2D *p2, double *ret);
 extern int lwgeom_pt_inside_circle(POINT2D *p, double cx, double cy, double rad);
 extern char ptarray_isccw(const POINTARRAY *pa);
 extern void lwgeom_reverse(LWGEOM *lwgeom);
@@ -1223,17 +1234,17 @@ extern void lwline_reverse(LWLINE *line);
 extern void lwpoly_reverse(LWPOLY *poly);
 extern void lwpoly_forceRHR(LWPOLY *poly);
 extern void lwgeom_force_rhr(LWGEOM *lwgeom);
-extern char *lwgeom_summary(LWGEOM *lwgeom, int offset);
-extern const char *lwgeom_typename(int type);
+extern char* lwgeom_summary(const LWGEOM *lwgeom, int offset);
+extern const char *lwtype_name(int type);
 extern int ptarray_compute_box2d_p(const POINTARRAY *pa, BOX2DFLOAT4 *result);
 extern BOX2DFLOAT4 *ptarray_compute_box2d(const POINTARRAY *pa);
-extern int lwpoint_compute_box2d_p(LWPOINT *point, BOX2DFLOAT4 *box);
-extern int lwline_compute_box2d_p(LWLINE *line, BOX2DFLOAT4 *box);
-extern int lwpoly_compute_box2d_p(LWPOLY *poly, BOX2DFLOAT4 *box);
-extern int lwcollection_compute_box2d_p(LWCOLLECTION *col, BOX2DFLOAT4 *box);
-extern int lwcircstring_compute_box2d_p(LWCIRCSTRING *curve, BOX2DFLOAT4 *box);
-extern BOX2DFLOAT4 *lwgeom_compute_box2d(LWGEOM *lwgeom);
-extern char * lwpoint_to_latlon(LWPOINT * p, const char * format);
+extern int lwpoint_compute_box2d_p(const LWPOINT *point, BOX2DFLOAT4 *box);
+extern int lwline_compute_box2d_p(const LWLINE *line, BOX2DFLOAT4 *box);
+extern int lwpoly_compute_box2d_p(const LWPOLY *poly, BOX2DFLOAT4 *box);
+extern int lwcollection_compute_box2d_p(const LWCOLLECTION *col, BOX2DFLOAT4 *box);
+extern int lwcircstring_compute_box2d_p(const LWCIRCSTRING *curve, BOX2DFLOAT4 *box);
+extern BOX2DFLOAT4* lwgeom_compute_box2d(const LWGEOM *lwgeom);
+extern char* lwpoint_to_latlon(const LWPOINT *p, const char *format);
 
 extern void interpolate_point4d(POINT4D *A, POINT4D *B, POINT4D *I, double F);
 
@@ -1242,7 +1253,7 @@ extern BOX2DFLOAT4 *box2d_union(BOX2DFLOAT4 *b1, BOX2DFLOAT4 *b2);
 
 /* args may overlap ! */
 extern int box2d_union_p(BOX2DFLOAT4 *b1, BOX2DFLOAT4 *b2, BOX2DFLOAT4 *ubox);
-extern int lwgeom_compute_box2d_p(LWGEOM *lwgeom, BOX2DFLOAT4 *box);
+extern int lwgeom_compute_box2d_p(const LWGEOM *lwgeom, BOX2DFLOAT4 *box);
 void lwgeom_longitude_shift(LWGEOM *lwgeom);
 
 
@@ -1260,8 +1271,8 @@ extern int lwgeom_needs_bbox(const LWGEOM *geom);
 /**
 * Count the total number of vertices in any #LWGEOM.
 */
-extern int lwgeom_count_vertices(LWGEOM *geom);
-extern int32 lwgeom_npoints(uchar *serialized);
+extern int lwgeom_count_vertices(const LWGEOM *geom);
+extern int lwgeom_npoints(uchar *serialized);
 
 /**
 * Return true or false depending on whether a geometry has
@@ -1288,27 +1299,6 @@ char lwline_same(const LWLINE *p1, const LWLINE *p2);
 char lwpoly_same(const LWPOLY *p1, const LWPOLY *p2);
 char lwcollection_same(const LWCOLLECTION *p1, const LWCOLLECTION *p2);
 
-/*
- * Add 'what' to 'to' at position 'where'.
- * where=0 == prepend
- * where=-1 == append
- * Mix of dimensions is not allowed (TODO: allow it?).
- * Returns a newly allocated LWGEOM (with NO BBOX)
- */
-extern LWGEOM *lwgeom_add(const LWGEOM *to, uint32 where, const LWGEOM *what);
-
-LWGEOM *lwpoint_add(const LWPOINT *to, uint32 where, const LWGEOM *what);
-LWGEOM *lwline_add(const LWLINE *to, uint32 where, const LWGEOM *what);
-LWGEOM *lwpoly_add(const LWPOLY *to, uint32 where, const LWGEOM *what);
-LWGEOM *lwmpoly_add(const LWMPOLY *to, uint32 where, const LWGEOM *what);
-LWGEOM *lwmline_add(const LWMLINE *to, uint32 where, const LWGEOM *what);
-LWGEOM *lwmpoint_add(const LWMPOINT *to, uint32 where, const LWGEOM *what);
-LWGEOM *lwcollection_add(const LWCOLLECTION *to, uint32 where, const LWGEOM *what);
-LWGEOM *lwcompound_add(const LWCOMPOUND *to, uint32 where, const LWGEOM *what);
-LWGEOM *lwcurvepoly_add(const LWCURVEPOLY *to, uint32 where, const LWGEOM *what);
-LWGEOM *lwmcurve_add(const LWMCURVE *to, uint32 where, const LWGEOM *what);
-LWGEOM *lwmsurface_add(const LWMSURFACE *to, uint32 where, const LWGEOM *what);
-LWGEOM *lwcircstring_add(const LWCIRCSTRING *to, uint32 where, const LWGEOM *what);
 
 /*
  * Clone an LWGEOM
@@ -1325,49 +1315,48 @@ extern BOX2DFLOAT4 *box2d_clone(const BOX2DFLOAT4 *lwgeom);
 extern POINTARRAY *ptarray_clone(const POINTARRAY *ptarray);
 
 /*
- * Geometry constructors
- * Take ownership of arguments
- */
-extern LWPOINT  *lwpoint_construct(int SRID, BOX2DFLOAT4 *bbox,
-                                   POINTARRAY *point);
-extern LWLINE *lwline_construct(int SRID, BOX2DFLOAT4 *bbox,
-                                POINTARRAY *points);
+* Geometry constructors. These constructors to not copy the point arrays
+* passed to them, they just take references, so do not free them out
+* from underneath the geometries.
+*/
+extern LWPOINT *lwpoint_construct(int SRID, BOX2DFLOAT4 *bbox, POINTARRAY *point);
+extern LWLINE *lwline_construct(int SRID, BOX2DFLOAT4 *bbox, POINTARRAY *points);
+extern LWCIRCSTRING *lwcircstring_construct(int SRID, BOX2DFLOAT4 *bbox, POINTARRAY *points);
+extern LWPOLY *lwpoly_construct(int SRID, BOX2DFLOAT4 *bbox, uint32 nrings, POINTARRAY **points);
+extern LWCOLLECTION *lwcollection_construct(uint32 type, int SRID, BOX2DFLOAT4 *bbox, uint32 ngeoms, LWGEOM **geoms);
 
 /*
- * Construct a new LWPOLY.  arrays (points/points per ring) will NOT be copied
- * use SRID=-1 for unknown SRID (will have 8bit type's S = 0)
- */
-extern LWPOLY *lwpoly_construct(int SRID, BOX2DFLOAT4 *bbox,
-                                unsigned int nrings, POINTARRAY **points);
-
-extern LWCOLLECTION *lwcollection_construct(unsigned int type, int SRID,
-        BOX2DFLOAT4 *bbox, unsigned int ngeoms, LWGEOM **geoms);
-extern LWCOLLECTION *lwcollection_construct_empty(int SRID,
-        char hasZ, char hasM);
+* Empty geometry constructors.
+*/
+extern LWPOINT* lwpoint_construct_empty(int srid, char hasz, char hasm);
+extern LWLINE* lwline_construct_empty(int srid, char hasz, char hasm);
+extern LWPOLY* lwpoly_construct_empty(int srid, char hasz, char hasm);
+extern LWMPOINT* lwmpoint_construct_empty(int srid, char hasz, char hasm);
+extern LWMLINE* lwmline_construct_empty(int srid, char hasz, char hasm);
+extern LWMPOLY* lwmpoly_construct_empty(int srid, char hasz, char hasm);
+extern LWCOLLECTION* lwcollection_construct_empty(int srid, char hasz, char hasm);
 
-/*
- * Construct a new LWCIRCSTRING.  arrays (points/points per ring) will NOT be copied
- * use SRID=-1 for unknown SRID (will have 8bit type's S = 0)
- */
-extern LWCIRCSTRING *lwcircstring_construct(int SRID, BOX2DFLOAT4 *bbox, POINTARRAY *points);
 
 /* Other constructors */
 extern LWPOINT *make_lwpoint2d(int SRID, double x, double y);
 extern LWPOINT *make_lwpoint3dz(int SRID, double x, double y, double z);
 extern LWPOINT *make_lwpoint3dm(int SRID, double x, double y, double m);
 extern LWPOINT *make_lwpoint4d(int SRID, double x, double y, double z, double m);
-extern LWLINE *lwline_from_lwpointarray(int SRID, unsigned int npoints, LWPOINT **points);
+extern LWLINE *lwline_from_lwpointarray(int SRID, uint32 npoints, LWPOINT **points);
 extern LWLINE *lwline_from_lwmpoint(int SRID, LWMPOINT *mpoint);
-extern LWLINE *lwline_addpoint(LWLINE *line, LWPOINT *point, unsigned int where);
-extern LWLINE *lwline_removepoint(LWLINE *line, unsigned int which);
-extern void lwline_setPoint4d(LWLINE *line, unsigned int which, POINT4D *newpoint);
-extern LWPOLY *lwpoly_from_lwlines(const LWLINE *shell, unsigned int nholes, const LWLINE **holes);
+extern LWLINE *lwline_addpoint(LWLINE *line, LWPOINT *point, uint32 where);
+extern LWLINE *lwline_removepoint(LWLINE *line, uint32 which);
+extern void lwline_setPoint4d(LWLINE *line, uint32 which, POINT4D *newpoint);
+extern LWPOLY *lwpoly_from_lwlines(const LWLINE *shell, uint32 nholes, const LWLINE **holes);
 
 /* Return a char string with ASCII versionf of type flags */
 extern const char *lwgeom_typeflags(uchar type);
 
 /* Construct an empty pointarray */
-extern POINTARRAY *ptarray_construct(char hasz, char hasm, unsigned int npoints);
+extern POINTARRAY* ptarray_construct(char hasz, char hasm, uint32 npoints);
+
+/* Construct a pointarray, *copying* in the data from ptlist */
+extern POINTARRAY* ptarray_construct_copy_data(char hasz, char hasm, uint32 npoints, uchar *ptlist);
 
 /*
  * extern POINTARRAY *ptarray_construct2d(uint32 npoints, const POINT2D *pts);
@@ -1377,8 +1366,8 @@ extern POINTARRAY *ptarray_construct(char hasz, char hasm, unsigned int npoints)
  */
 
 extern POINTARRAY *ptarray_addPoint(const POINTARRAY *pa, uchar *p, size_t pdims,
-                                    unsigned int where);
-extern POINTARRAY *ptarray_removePoint(POINTARRAY *pa, unsigned int where);
+                                    uint32 where);
+extern POINTARRAY *ptarray_removePoint(POINTARRAY *pa, uint32 where);
 extern POINTARRAY *ptarray_merge(POINTARRAY *pa1, POINTARRAY *pa2);
 
 extern int ptarray_isclosed2d(const POINTARRAY *pa);
@@ -1415,7 +1404,7 @@ extern LWMLINE* lwmline_measured_from_lwmline(const LWMLINE *lwmline, double m_s
  * Returned LWGEOM might is unchanged if a POINT.
  */
 extern LWGEOM *lwgeom_segmentize2d(LWGEOM *line, double dist);
-extern POINTARRAY *ptarray_segmentize2d(POINTARRAY *ipa, double dist);
+extern POINTARRAY *ptarray_segmentize2d(const POINTARRAY *ipa, double dist);
 extern LWLINE *lwline_segmentize2d(LWLINE *line, double dist);
 extern LWPOLY *lwpoly_segmentize2d(LWPOLY *line, double dist);
 extern LWCOLLECTION *lwcollection_segmentize2d(LWCOLLECTION *coll, double dist);
@@ -1429,11 +1418,11 @@ extern LWCOLLECTION *lwcollection_segmentize2d(LWCOLLECTION *coll, double dist);
 #define OUT_MAX_DOUBLE_PRECISION 15
 #define OUT_MAX_DIGS_DOUBLE (OUT_SHOW_DIGS_DOUBLE + 2) /* +2 mean add dot and sign */
 
-extern char * lwgeom_to_gml2(uchar *geom, char *srs, int precision);
-extern char * lwgeom_to_gml3(uchar *geom, char *srs, int precision, int is_deegree);
-extern char * lwgeom_to_kml2(uchar *geom, int precision);
-extern char * lwgeom_to_geojson(uchar *geom, char *srs, int precision, int has_bbox);
-extern char * lwgeom_to_svg(uchar *geom, int precision, int relative);
+extern char* lwgeom_to_gml2(uchar *geom, char *srs, int precision);
+extern char* lwgeom_to_gml3(uchar *geom, char *srs, int precision, int is_deegree);
+extern char* lwgeom_to_kml2(uchar *geom, int precision);
+extern char* lwgeom_to_geojson(uchar *geom, char *srs, int precision, int has_bbox);
+extern char* lwgeom_to_svg(uchar *geom, int precision, int relative);
 
 
 extern POINTARRAY *ptarray_remove_repeated_points(POINTARRAY *in);
@@ -1451,7 +1440,7 @@ extern void deparse_hex(uchar str, char *result);
 /*
 ** New parsing and unparsing functions.
 */
-extern char *lwgeom_to_wkt(const LWGEOM *geom, uchar variant, int precision, size_t *size_out);
+extern charlwgeom_to_wkt(const LWGEOM *geom, uchar variant, int precision, size_t *size_out);
 extern char* lwgeom_to_wkb(const LWGEOM *geom, uchar variant, size_t *size_out);
 
 
@@ -1511,16 +1500,16 @@ LWGEOM_UNPARSER_RESULT;
 
 /* Parser access routines */
 extern char *lwgeom_to_ewkt(LWGEOM *lwgeom, int flags);
-extern char *lwgeom_to_hexwkb(LWGEOM *lwgeom, int flags, unsigned int byteorder);
+extern char *lwgeom_to_hexwkb(LWGEOM *lwgeom, int flags, uint32 byteorder);
 extern LWGEOM *lwgeom_from_ewkb(uchar *ewkb, int flags, size_t ewkblen);
 extern LWGEOM *lwgeom_from_ewkt(char *ewkt, int flags);
 extern uchar *lwgeom_to_ewkb(LWGEOM *lwgeom, int flags, char byteorder, size_t *ewkblen);
 
 extern int serialized_lwgeom_to_ewkt(LWGEOM_UNPARSER_RESULT *lwg_unparser_result, uchar *serialized, int flags);
 extern int serialized_lwgeom_from_ewkt(LWGEOM_PARSER_RESULT *lwg_parser_result, char *wkt_input, int flags);
-extern int serialized_lwgeom_to_hexwkb(LWGEOM_UNPARSER_RESULT *lwg_unparser_result, uchar *serialized, int flags, unsigned int byteorder);
+extern int serialized_lwgeom_to_hexwkb(LWGEOM_UNPARSER_RESULT *lwg_unparser_result, uchar *serialized, int flags, uint32 byteorder);
 extern int serialized_lwgeom_from_hexwkb(LWGEOM_PARSER_RESULT *lwg_parser_result, char *hexwkb_input, int flags);
-extern int serialized_lwgeom_to_ewkb(LWGEOM_UNPARSER_RESULT *lwg_unparser_result, uchar *serialized, int flags, unsigned int byteorder);
+extern int serialized_lwgeom_to_ewkb(LWGEOM_UNPARSER_RESULT *lwg_unparser_result, uchar *serialized, int flags, uint32 byteorder);
 
 extern void *lwalloc(size_t size);
 extern void *lwrealloc(void *mem, size_t size);
@@ -1542,7 +1531,7 @@ void errorIfSRIDMismatch(int srid1, int srid2);
  * SQLMM internal functions - TODO: Move into separate header files
  ******************************************************************************/
 
-uint32 has_arc(LWGEOM *geom);
+int has_arc(const LWGEOM *geom);
 double lwcircle_center(POINT4D *p1, POINT4D *p2, POINT4D *p3, POINT4D **result);
 LWGEOM *lwgeom_segmentize(LWGEOM *geom, uint32 perQuad);
 LWGEOM *lwgeom_desegmentize(LWGEOM *geom);
index c4472d27f794bce045514d67edb0720ff6018324..77a14f3194859fa7e2bb63b6d2233b72396552ba 100644 (file)
@@ -24,11 +24,11 @@ void lwcircstring_reverse(LWCIRCSTRING *curve);
 void lwcircstring_release(LWCIRCSTRING *lwcirc);
 LWCIRCSTRING *lwcircstring_segmentize2d(LWCIRCSTRING *curve, double dist);
 char lwcircstring_same(const LWCIRCSTRING *me, const LWCIRCSTRING *you);
-LWCIRCSTRING *lwcircstring_from_lwpointarray(int SRID, unsigned int npoints, LWPOINT **points);
+LWCIRCSTRING *lwcircstring_from_lwpointarray(int SRID, uint32 npoints, LWPOINT **points);
 LWCIRCSTRING *lwcircstring_from_lwmpoint(int SRID, LWMPOINT *mpoint);
-LWCIRCSTRING *lwcircstring_addpoint(LWCIRCSTRING *curve, LWPOINT *point, unsigned int where);
-LWCIRCSTRING *lwcircstring_removepoint(LWCIRCSTRING *curve, unsigned int index);
-void lwcircstring_setPoint4d(LWCIRCSTRING *curve, unsigned int index, POINT4D *newpoint);
+LWCIRCSTRING *lwcircstring_addpoint(LWCIRCSTRING *curve, LWPOINT *point, uint32 where);
+LWCIRCSTRING *lwcircstring_removepoint(LWCIRCSTRING *curve, uint32 index);
+void lwcircstring_setPoint4d(LWCIRCSTRING *curve, uint32 index, POINT4D *newpoint);
 
 
 
@@ -89,7 +89,7 @@ lwcircstring_deserialize(uchar *serialized_form)
        type = (uchar)serialized_form[0];
        if (lwgeom_getType(type) != CIRCSTRINGTYPE)
        {
-               lwerror("lwcircstring_deserialize: attempt to deserialize a circularstring which is really a %s", lwgeom_typename(type));
+               lwerror("lwcircstring_deserialize: attempt to deserialize a circularstring which is really a %s", lwtype_name(type));
                return NULL;
        }
 
@@ -455,7 +455,7 @@ lwcircle_compute_box3d(POINT4D *p1, POINT4D *p2, POINT4D *p3)
  * TODO: This ignores curvature, which should be taken into account.
  */
 BOX3D *
-lwcircstring_compute_box3d(LWCIRCSTRING *curve)
+lwcircstring_compute_box3d(const LWCIRCSTRING *curve)
 {
        BOX3D *box, *tmp;
        int i;
@@ -496,7 +496,7 @@ lwcircstring_compute_box3d(LWCIRCSTRING *curve)
 
 
 int
-lwcircstring_compute_box2d_p(LWCIRCSTRING *curve, BOX2DFLOAT4 *result)
+lwcircstring_compute_box2d_p(const LWCIRCSTRING *curve, BOX2DFLOAT4 *result)
 {
        BOX3D *box = lwcircstring_compute_box3d(curve);
        LWDEBUG(2, "lwcircstring_compute_box2d_p called.");
@@ -569,57 +569,6 @@ lwcircstring_clone(const LWCIRCSTRING *g)
        return ret;
 }
 
-/*
- * Add 'what' to this curve at position 'where'.
- * where=0 == prepend
- * where=-1 == append
- * Returns a MULTICURVE or a GEOMETRYCOLLECTION
- */
-LWGEOM *
-lwcircstring_add(const LWCIRCSTRING *to, uint32 where, const LWGEOM *what)
-{
-       LWCOLLECTION *col;
-       LWGEOM **geoms;
-       int newtype;
-
-       if (where != -1 && where != 0)
-       {
-               lwerror("lwcurve_add only supports 0 or -1 as second argument %d", where);
-               return NULL;
-       }
-
-       /* dimensions compatibility are checked by caller */
-
-       /* Construct geoms array */
-       geoms = lwalloc(sizeof(LWGEOM *)*2);
-       if (where == -1) /* append */
-       {
-               geoms[0] = lwgeom_clone((LWGEOM *)to);
-               geoms[1] = lwgeom_clone(what);
-       }
-       else /* prepend */
-       {
-               geoms[0] = lwgeom_clone(what);
-               geoms[1] = lwgeom_clone((LWGEOM *)to);
-       }
-
-       /* reset SRID and wantbbox flag from component types */
-       geoms[0]->SRID = geoms[1]->SRID = -1;
-       TYPE_SETHASSRID(geoms[0]->type, 0);
-       TYPE_SETHASSRID(geoms[1]->type, 0);
-       TYPE_SETHASBBOX(geoms[0]->type, 0);
-       TYPE_SETHASBBOX(geoms[1]->type, 0);
-
-       /* Find appropriate geom type */
-       if (TYPE_GETTYPE(what->type) == CIRCSTRINGTYPE || TYPE_GETTYPE(what->type) == LINETYPE) newtype = MULTICURVETYPE;
-       else newtype = COLLECTIONTYPE;
-
-       col = lwcollection_construct(newtype,
-                                    to->SRID, NULL,
-                                    2, geoms);
-
-       return (LWGEOM *)col;
-}
 
 void lwcircstring_reverse(LWCIRCSTRING *curve)
 {
@@ -648,10 +597,10 @@ lwcircstring_same(const LWCIRCSTRING *me, const LWCIRCSTRING *you)
  * LWCIRCSTRING dimensions are large enough to host all input dimensions.
  */
 LWCIRCSTRING *
-lwcircstring_from_lwpointarray(int SRID, unsigned int npoints, LWPOINT **points)
+lwcircstring_from_lwpointarray(int SRID, uint32 npoints, LWPOINT **points)
 {
        int zmflag=0;
-       unsigned int i;
+       uint32 i;
        POINTARRAY *pa;
        uchar *newpoints, *ptr;
        size_t ptsize, size;
@@ -664,7 +613,7 @@ lwcircstring_from_lwpointarray(int SRID, unsigned int npoints, LWPOINT **points)
                if (TYPE_GETTYPE(points[i]->type) != POINTTYPE)
                {
                        lwerror("lwcurve_from_lwpointarray: invalid input type: %s",
-                               lwgeom_typename(TYPE_GETTYPE(points[i]->type)));
+                               lwtype_name(TYPE_GETTYPE(points[i]->type)));
                        return NULL;
                }
                if (TYPE_HASZ(points[i]->type)) zmflag |= 2;
@@ -701,7 +650,7 @@ lwcircstring_from_lwpointarray(int SRID, unsigned int npoints, LWPOINT **points)
 LWCIRCSTRING *
 lwcircstring_from_lwmpoint(int SRID, LWMPOINT *mpoint)
 {
-       unsigned int i;
+       uint32 i;
        POINTARRAY *pa;
        char zmflag = TYPE_GETZM(mpoint->type);
        size_t ptsize, size;
@@ -734,7 +683,7 @@ lwcircstring_from_lwmpoint(int SRID, LWMPOINT *mpoint)
 }
 
 LWCIRCSTRING *
-lwcircstring_addpoint(LWCIRCSTRING *curve, LWPOINT *point, unsigned int where)
+lwcircstring_addpoint(LWCIRCSTRING *curve, LWPOINT *point, uint32 where)
 {
        POINTARRAY *newpa;
        LWCIRCSTRING *ret;
@@ -748,7 +697,7 @@ lwcircstring_addpoint(LWCIRCSTRING *curve, LWPOINT *point, unsigned int where)
 }
 
 LWCIRCSTRING *
-lwcircstring_removepoint(LWCIRCSTRING *curve, unsigned int index)
+lwcircstring_removepoint(LWCIRCSTRING *curve, uint32 index)
 {
        POINTARRAY *newpa;
        LWCIRCSTRING *ret;
@@ -763,7 +712,7 @@ lwcircstring_removepoint(LWCIRCSTRING *curve, unsigned int index)
  * Note: input will be changed, make sure you have permissions for this.
  * */
 void
-lwcircstring_setPoint4d(LWCIRCSTRING *curve, unsigned int index, POINT4D *newpoint)
+lwcircstring_setPoint4d(LWCIRCSTRING *curve, uint32 index, POINT4D *newpoint)
 {
        setPoint4d(curve->points, index, newpoint);
 }
index e9029ca4bb55dcbe71c700c33b16aa4a386822b9..8427696d13d5dd2fe39699584a6c11cbc89461c4 100644 (file)
@@ -26,14 +26,14 @@ lwcollection_release(LWCOLLECTION *lwcollection)
 
 
 LWCOLLECTION *
-lwcollection_construct(unsigned int type, int SRID, BOX2DFLOAT4 *bbox,
-                       unsigned int ngeoms, LWGEOM **geoms)
+lwcollection_construct(uint32 type, int SRID, BOX2DFLOAT4 *bbox,
+                       uint32 ngeoms, LWGEOM **geoms)
 {
        LWCOLLECTION *ret;
        int hasz, hasm;
 #ifdef CHECK_LWGEOM_ZM
        char zm;
-       unsigned int i;
+       uint32 i;
 #endif
 
        LWDEBUGF(2, "lwcollection_construct called with %d, %d, %p, %d, %p.", type, SRID, bbox, ngeoms, geoms);
@@ -65,6 +65,7 @@ lwcollection_construct(unsigned int type, int SRID, BOX2DFLOAT4 *bbox,
                                         type, 0);
        ret->SRID = SRID;
        ret->ngeoms = ngeoms;
+       ret->maxgeoms = ngeoms;
        ret->geoms = geoms;
        ret->bbox = bbox;
 
@@ -72,15 +73,15 @@ lwcollection_construct(unsigned int type, int SRID, BOX2DFLOAT4 *bbox,
 }
 
 LWCOLLECTION *
-lwcollection_construct_empty(int SRID, char hasz, char hasm)
+lwcollection_construct_empty(int srid, char hasz, char hasm)
 {
        LWCOLLECTION *ret;
 
        ret = lwalloc(sizeof(LWCOLLECTION));
-       ret->type = lwgeom_makeType_full(hasz, hasm, (SRID!=-1),
-                                        COLLECTIONTYPE, 0);
-       ret->SRID = SRID;
+       ret->type = lwgeom_makeType_full(hasz, hasm, (srid!=-1), COLLECTIONTYPE, 0);
+       ret->SRID = srid;
        ret->ngeoms = 0;
+       ret->maxgeoms = 0;
        ret->geoms = NULL;
        ret->bbox = NULL;
 
@@ -185,7 +186,7 @@ lwcollection_serialize_buf(LWCOLLECTION *coll, uchar *buf, size_t *retsize)
        int i;
 
        LWDEBUGF(2, "lwcollection_serialize_buf called (%s with %d elems)",
-                lwgeom_typename(TYPE_GETTYPE(coll->type)), coll->ngeoms);
+                lwtype_name(TYPE_GETTYPE(coll->type)), coll->ngeoms);
 
        hasSRID = (coll->SRID != -1);
 
@@ -231,7 +232,7 @@ lwcollection_serialize_buf(LWCOLLECTION *coll, uchar *buf, size_t *retsize)
 }
 
 int
-lwcollection_compute_box2d_p(LWCOLLECTION *col, BOX2DFLOAT4 *box)
+lwcollection_compute_box2d_p(const LWCOLLECTION *col, BOX2DFLOAT4 *box)
 {
        BOX2DFLOAT4 boxbuf;
        uint32 i;
@@ -275,57 +276,54 @@ lwcollection_clone(const LWCOLLECTION *g)
        return ret;
 }
 
-/** @brief Add 'what' to this to #LWCOLLECTION at position 'where'.
- *                     where=0 then prepend
- *                     where=-1 then append
- * Returns a GEOMETRYCOLLECTION
- */
-LWGEOM *
-lwcollection_add(const LWCOLLECTION *to, uint32 where, const LWGEOM *what)
+/** 
+* Appends geom to the collection managed by col. Does not copy or
+* clone, simply takes a reference on the passed geom.
+*/
+LWCOLLECTION* lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
 {
-       LWCOLLECTION *col;
-       LWGEOM **geoms;
-       uint32 i;
+       int i = 0;
+       
+       if( col == NULL || geom == NULL ) return NULL;
 
-       if ( where == -1 ) where = to->ngeoms;
-       else if ( where < -1 || where > to->ngeoms )
+       if( col->geoms == NULL && (col->ngeoms || col->maxgeoms) )
+               lwerror("Collection is in inconsistent state. Null memory but non-zero collection counts.");
+
+       /* In case this is a truly empty, make some initial space  */
+       if( col->geoms == NULL )
        {
-               lwerror("lwcollection_add: add position out of range %d..%d", -1, to->ngeoms);
-               return NULL;
+               col->maxgeoms = 2;
+               col->ngeoms = 0;
+               col->geoms = lwalloc(col->maxgeoms * sizeof(LWGEOM*));
        }
-
-       /* dimensions compatibility are checked by caller */
-
-       /* Construct geoms array */
-       geoms = lwalloc(sizeof(LWGEOM *)*(to->ngeoms+1));
-       for (i=0; i<where; i++)
+       
+       /* Allocate more space if we need it */
+       if( col->ngeoms == col->maxgeoms )
        {
-               geoms[i] = lwgeom_clone(to->geoms[i]);
-               lwgeom_dropSRID(geoms[i]);
-               lwgeom_drop_bbox(geoms[i]);
+               col->geoms = lwrealloc(col->geoms, sizeof(LWGEOM*) * col->maxgeoms * 2);
+               col->maxgeoms *= 2;
        }
-       geoms[where] = lwgeom_clone(what);
-       lwgeom_dropSRID(geoms[where]);
-       lwgeom_drop_bbox(geoms[where]);
-       for (i=where; i<to->ngeoms; i++)
+       
+       /* Make sure we don't already have a reference to this geom */
+       for( i = 0; i < col->ngeoms; i++ )
        {
-               geoms[i+1] = lwgeom_clone(to->geoms[i]);
-               lwgeom_dropSRID(geoms[i+1]);
-               lwgeom_drop_bbox(geoms[i+1]);
+               if( col->geoms[i] == geom )
+               {
+                       LWDEBUGF(4, "Found duplicate geometry in collection %p == %p", col->geoms[i], geom);
+                       return col;
+               }
        }
 
-       col = lwcollection_construct(COLLECTIONTYPE,
-                                    to->SRID, NULL,
-                                    to->ngeoms+1, geoms);
-
-       return (LWGEOM *)col;
-
+       col->geoms[col->ngeoms] = (LWGEOM*)geom;
+       col->ngeoms++;
+       return col;
 }
 
+
 LWCOLLECTION *
 lwcollection_segmentize2d(LWCOLLECTION *col, double dist)
 {
-       unsigned int i;
+       uint32 i;
        LWGEOM **newgeoms;
 
        if ( ! col->ngeoms ) return lwcollection_clone(col);
@@ -343,7 +341,7 @@ lwcollection_segmentize2d(LWCOLLECTION *col, double dist)
 char
 lwcollection_same(const LWCOLLECTION *c1, const LWCOLLECTION *c2)
 {
-       unsigned int i;
+       uint32 i;
 
        LWDEBUG(2, "lwcollection_same called");
 
@@ -358,8 +356,8 @@ lwcollection_same(const LWCOLLECTION *c1, const LWCOLLECTION *c2)
 
        /* Former method allowed out-of-order equality between collections
 
-               hit = lwalloc(sizeof(unsigned int)*c1->ngeoms);
-               memset(hit, 0, sizeof(unsigned int)*c1->ngeoms);
+               hit = lwalloc(sizeof(uint32)*c1->ngeoms);
+               memset(hit, 0, sizeof(uint32)*c1->ngeoms);
 
                for (i=0; i<c1->ngeoms; i++)
                {
@@ -544,7 +542,7 @@ LWCOLLECTION* lwcollection_extract(LWCOLLECTION *col, int type)
                outtype = MULTIPOLYGONTYPE;
                break;
        default:
-               lwerror("Only POLYGON, LINESTRING and POINT are supported by lwcollection_extract. %s requested.", lwgeom_typename(type));
+               lwerror("Only POLYGON, LINESTRING and POINT are supported by lwcollection_extract. %s requested.", lwtype_name(type));
                return NULL;
        }
 
@@ -608,7 +606,7 @@ LWCOLLECTION* lwcollection_extract(LWCOLLECTION *col, int type)
 LWGEOM*
 lwcollection_remove_repeated_points(LWCOLLECTION *coll)
 {
-       unsigned int i;
+       uint32 i;
        LWGEOM **newgeoms;
 
        newgeoms = lwalloc(sizeof(LWGEOM *)*coll->ngeoms);
index b420efac96cced022e81e3f0d467851a128455bc..5690655082b4972a1d71f32c9a77b570390b6798 100644 (file)
@@ -63,56 +63,5 @@ lwcompound_deserialize(uchar *serialized)
        return result;
 }
 
-/**
- * Add 'what' to this string at position 'where'
- * @param where if = 0 then prepend, if -1  then append
- * @param what an #LWGEOM object
- * @return a {@link #LWCOMPOUND} or a {@link #GEOMETRYCOLLECTION}
- */
-LWGEOM *
-lwcompound_add(const LWCOMPOUND *to, uint32 where, const LWGEOM *what)
-{
-       LWCOLLECTION *col;
-       LWGEOM **geoms;
-       int newtype;
-
-       LWDEBUG(2, "lwcompound_add called.");
-
-       if (where != -1 && where != 0)
-       {
-               lwerror("lwcompound_add only supports 0 or -1 as a second argument, not %d", where);
-               return NULL;
-       }
-
-       /* dimensions compatibility are checked by caller */
-
-       /* Construct geoms array */
-       geoms = lwalloc(sizeof(LWGEOM *)*2);
-       if (where == -1) /* append */
-       {
-               geoms[0] = lwgeom_clone((LWGEOM *)to);
-               geoms[1] = lwgeom_clone(what);
-       }
-       else /* prepend */
-       {
-               geoms[0] = lwgeom_clone(what);
-               geoms[1] = lwgeom_clone((LWGEOM *)to);
-       }
 
-       /* reset SRID and wantbbox flag from component types */
-       geoms[0]->SRID = geoms[1]->SRID = -1;
-       TYPE_SETHASSRID(geoms[0]->type, 0);
-       TYPE_SETHASSRID(geoms[1]->type, 0);
-       TYPE_SETHASBBOX(geoms[0]->type, 0);
-       TYPE_SETHASBBOX(geoms[1]->type, 0);
-
-       /* Find appropriate geom type */
-       if (TYPE_GETTYPE(what->type) == LINETYPE || TYPE_GETTYPE(what->type) == CIRCSTRINGTYPE) newtype = COMPOUNDTYPE;
-       else newtype = COLLECTIONTYPE;
-
-       col = lwcollection_construct(newtype,
-                                    to->SRID, NULL, 2, geoms);
-
-       return (LWGEOM *)col;
-}
 
index b7be189864914c5c3e690ad4a939294ca77b4bb2..9e8f2ff6cfb219fbfeb71b97ef449a2b98838f69 100644 (file)
@@ -57,7 +57,7 @@ lwcurvepoly_deserialize(uchar *srl)
                        && lwgeom_getType(result->rings[i]->type) != LINETYPE
                        && lwgeom_getType(result->rings[i]->type) != COMPOUNDTYPE)
                {
-                       lwerror("Only Circular curves, Linestrings and Compound curves are supported as rings, not %s (%d)", lwgeom_typename(result->rings[i]->type), result->rings[i]->type);
+                       lwerror("Only Circular curves, Linestrings and Compound curves are supported as rings, not %s (%d)", lwtype_name(result->rings[i]->type), result->rings[i]->type);
                        lwfree(result);
                        lwfree(insp);
                        return NULL;
@@ -75,13 +75,5 @@ lwcurvepoly_deserialize(uchar *srl)
        return result;
 }
 
-LWGEOM *
-lwcurvepoly_add(const LWCURVEPOLY *to, uint32 where, const LWGEOM *what)
-{
-       /* TODO */
-       lwerror("lwcurvepoly_add not yet implemented.");
-       return NULL;
-}
-
 
 
index 7851d041bb480afeabfecdf8713905457ea994ed..d0b462fdb415a5fef08683d03d9ecbbbc0eb5c30 100644 (file)
@@ -1977,7 +1977,7 @@ double lwgeom_distance_spheroid(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2, co
        }
 
 
-       lwerror("arguments include unsupported geometry type (%s, %s)", lwgeom_typename(type1), lwgeom_typename(type1));
+       lwerror("arguments include unsupported geometry type (%s, %s)", lwtype_name(type1), lwtype_name(type1));
        return -1.0;
 
 }
index 43ef716cc569729a6907f8615f93f988b75cf355..7a4d78e920f37cae08f48577e3c49658e8679f96 100644 (file)
@@ -23,7 +23,7 @@ lwgeom_deserialize(uchar *srl)
 {
        int type = lwgeom_getType(srl[0]);
 
-       LWDEBUGF(2, "lwgeom_deserialize got %d - %s", type, lwgeom_typename(type));
+       LWDEBUGF(2, "lwgeom_deserialize got %d - %s", type, lwtype_name(type));
 
        switch (type)
        {
@@ -53,7 +53,7 @@ lwgeom_deserialize(uchar *srl)
                return (LWGEOM *)lwmsurface_deserialize(srl);
        default:
                lwerror("lwgeom_deserialize: Unknown geometry type: %s",
-                       lwgeom_typename(type));
+                       lwtype_name(type));
 
                return NULL;
        }
@@ -65,7 +65,7 @@ lwgeom_serialize_size(LWGEOM *lwgeom)
 {
        int type = TYPE_GETTYPE(lwgeom->type);
 
-       LWDEBUGF(2, "lwgeom_serialize_size(%s) called", lwgeom_typename(type));
+       LWDEBUGF(2, "lwgeom_serialize_size(%s) called", lwtype_name(type));
 
        switch (type)
        {
@@ -88,7 +88,7 @@ lwgeom_serialize_size(LWGEOM *lwgeom)
                return lwcollection_serialize_size((LWCOLLECTION *)lwgeom);
        default:
                lwerror("lwgeom_serialize_size: Unknown geometry type: %s",
-                       lwgeom_typename(type));
+                       lwtype_name(type));
 
                return 0;
        }
@@ -100,7 +100,7 @@ lwgeom_serialize_buf(LWGEOM *lwgeom, uchar *buf, size_t *retsize)
        int type = TYPE_GETTYPE(lwgeom->type);
 
        LWDEBUGF(2, "lwgeom_serialize_buf called with a %s",
-                lwgeom_typename(type));
+                lwtype_name(type));
 
        switch (type)
        {
@@ -129,7 +129,7 @@ lwgeom_serialize_buf(LWGEOM *lwgeom, uchar *buf, size_t *retsize)
                break;
        default:
                lwerror("lwgeom_serialize_buf: Unknown geometry type: %s",
-                       lwgeom_typename(type));
+                       lwtype_name(type));
                return;
        }
        return;
@@ -232,10 +232,10 @@ BOX3D *lwgeom_compute_box3d(const LWGEOM *lwgeom)
 
 
 int
-lwgeom_compute_box2d_p(LWGEOM *lwgeom, BOX2DFLOAT4 *buf)
+lwgeom_compute_box2d_p(const LWGEOM *lwgeom, BOX2DFLOAT4 *buf)
 {
        LWDEBUGF(2, "lwgeom_compute_box2d_p called of %p of type %s.",
-               lwgeom, lwgeom_typename(TYPE_GETTYPE(lwgeom->type)));
+               lwgeom, lwtype_name(TYPE_GETTYPE(lwgeom->type)));
 
        switch (TYPE_GETTYPE(lwgeom->type))
        {
@@ -263,8 +263,8 @@ lwgeom_compute_box2d_p(LWGEOM *lwgeom, BOX2DFLOAT4 *buf)
 /**
  * do not forget to lwfree() result
  */
-BOX2DFLOAT4 *
-lwgeom_compute_box2d(LWGEOM *lwgeom)
+BOX2DFLOAT4*
+lwgeom_compute_box2d(const LWGEOM *lwgeom)
 {
        BOX2DFLOAT4 *result = lwalloc(sizeof(BOX2DFLOAT4));
        if ( lwgeom_compute_box2d_p(lwgeom, result) ) return result;
@@ -276,100 +276,115 @@ lwgeom_compute_box2d(LWGEOM *lwgeom)
 }
 
 LWPOINT *
-lwgeom_as_lwpoint(LWGEOM *lwgeom)
+lwgeom_as_lwpoint(const LWGEOM *lwgeom)
 {
+       if( lwgeom == NULL ) return NULL;
        if ( TYPE_GETTYPE(lwgeom->type) == POINTTYPE )
                return (LWPOINT *)lwgeom;
        else return NULL;
 }
 
 LWLINE *
-lwgeom_as_lwline(LWGEOM *lwgeom)
+lwgeom_as_lwline(const LWGEOM *lwgeom)
 {
+       if( lwgeom == NULL ) return NULL;
        if ( TYPE_GETTYPE(lwgeom->type) == LINETYPE )
                return (LWLINE *)lwgeom;
        else return NULL;
 }
 
 LWCIRCSTRING *
-lwgeom_as_lwcircstring(LWGEOM *lwgeom)
+lwgeom_as_lwcircstring(const LWGEOM *lwgeom)
 {
+       if( lwgeom == NULL ) return NULL;
        if ( TYPE_GETTYPE(lwgeom->type) == CIRCSTRINGTYPE )
                return (LWCIRCSTRING *)lwgeom;
        else return NULL;
 }
 
 LWPOLY *
-lwgeom_as_lwpoly(LWGEOM *lwgeom)
+lwgeom_as_lwpoly(const LWGEOM *lwgeom)
 {
+       if( lwgeom == NULL ) return NULL;
        if ( TYPE_GETTYPE(lwgeom->type) == POLYGONTYPE )
                return (LWPOLY *)lwgeom;
        else return NULL;
 }
 
 LWCOLLECTION *
-lwgeom_as_lwcollection(LWGEOM *lwgeom)
+lwgeom_as_lwcollection(const LWGEOM *lwgeom)
 {
-       if ( TYPE_GETTYPE(lwgeom->type) >= MULTIPOINTTYPE
-               && TYPE_GETTYPE(lwgeom->type) <= COLLECTIONTYPE)
-               return (LWCOLLECTION *)lwgeom;
+       if( lwgeom == NULL ) return NULL;
+       if ( lwgeom_is_collection(TYPE_GETTYPE(lwgeom->type)) )
+               return (LWCOLLECTION*)lwgeom;
        else return NULL;
 }
 
 LWMPOINT *
-lwgeom_as_lwmpoint(LWGEOM *lwgeom)
+lwgeom_as_lwmpoint(const LWGEOM *lwgeom)
 {
+       if( lwgeom == NULL ) return NULL;
        if ( TYPE_GETTYPE(lwgeom->type) == MULTIPOINTTYPE )
                return (LWMPOINT *)lwgeom;
        else return NULL;
 }
 
 LWMLINE *
-lwgeom_as_lwmline(LWGEOM *lwgeom)
+lwgeom_as_lwmline(const LWGEOM *lwgeom)
 {
+       if( lwgeom == NULL ) return NULL;
        if ( TYPE_GETTYPE(lwgeom->type) == MULTILINETYPE )
                return (LWMLINE *)lwgeom;
        else return NULL;
 }
 
 LWMPOLY *
-lwgeom_as_lwmpoly(LWGEOM *lwgeom)
+lwgeom_as_lwmpoly(const LWGEOM *lwgeom)
 {
+       if( lwgeom == NULL ) return NULL;
        if ( TYPE_GETTYPE(lwgeom->type) == MULTIPOLYGONTYPE )
                return (LWMPOLY *)lwgeom;
        else return NULL;
 }
 
-LWGEOM *lwmpoly_as_lwgeom(LWMPOLY *obj)
+LWGEOM *lwmpoly_as_lwgeom(const LWMPOLY *obj)
 {
+       if( obj == NULL ) return NULL;
        return (LWGEOM *)obj;
 }
-LWGEOM *lwmline_as_lwgeom(LWMLINE *obj)
+LWGEOM *lwmline_as_lwgeom(const LWMLINE *obj)
 {
+       if( obj == NULL ) return NULL;
        return (LWGEOM *)obj;
 }
-LWGEOM *lwmpoint_as_lwgeom(LWMPOINT *obj)
+LWGEOM *lwmpoint_as_lwgeom(const LWMPOINT *obj)
 {
+       if( obj == NULL ) return NULL;
        return (LWGEOM *)obj;
 }
-LWGEOM *lwcollection_as_lwgeom(LWCOLLECTION *obj)
+LWGEOM *lwcollection_as_lwgeom(const LWCOLLECTION *obj)
 {
+       if( obj == NULL ) return NULL;
        return (LWGEOM *)obj;
 }
-LWGEOM *lwcircstring_as_lwgeom(LWCIRCSTRING *obj)
+LWGEOM *lwcircstring_as_lwgeom(const LWCIRCSTRING *obj)
 {
+       if( obj == NULL ) return NULL;
        return (LWGEOM *)obj;
 }
-LWGEOM *lwpoly_as_lwgeom(LWPOLY *obj)
+LWGEOM *lwpoly_as_lwgeom(const LWPOLY *obj)
 {
+       if( obj == NULL ) return NULL;
        return (LWGEOM *)obj;
 }
-LWGEOM *lwline_as_lwgeom(LWLINE *obj)
+LWGEOM *lwline_as_lwgeom(const LWLINE *obj)
 {
+       if( obj == NULL ) return NULL;
        return (LWGEOM *)obj;
 }
-LWGEOM *lwpoint_as_lwgeom(LWPOINT *obj)
+LWGEOM *lwpoint_as_lwgeom(const LWPOINT *obj)
 {
+       if( obj == NULL ) return NULL;
        return (LWGEOM *)obj;
 }
 
@@ -377,7 +392,7 @@ LWGEOM *lwpoint_as_lwgeom(LWPOINT *obj)
 /**
 ** Look-up for the correct MULTI* type promotion for singleton types.
 */
-static unsigned char MULTITYPE[16] =
+static uchar MULTITYPE[16] =
 {
        0,
        MULTIPOINTTYPE,
@@ -395,7 +410,7 @@ static unsigned char MULTITYPE[16] =
 * Create a new LWGEOM of the appropriate MULTI* type.
 */
 LWGEOM *
-lwgeom_as_multi(LWGEOM *lwgeom)
+lwgeom_as_multi(const LWGEOM *lwgeom)
 {
        LWGEOM **ogeoms;
        LWGEOM *ogeom = NULL;
@@ -445,10 +460,12 @@ lwgeom_release(LWGEOM *lwgeom)
                lwerror("lwgeom_release: someone called on 0x0");
 #endif
 
+       LWDEBUGF(3, "releasing type %s", lwtype_name(TYPE_GETTYPE(lwgeom->type)));
+
        /* Drop bounding box (always a copy) */
        if ( lwgeom->bbox )
        {
-               LWDEBUG(3, "lwgeom_release: releasing bbox.");
+               LWDEBUGF(3, "lwgeom_release: releasing bbox. %p", lwgeom->bbox);
 
                lwfree(lwgeom->bbox);
        }
@@ -476,7 +493,7 @@ LWGEOM *
 lwgeom_clone(const LWGEOM *lwgeom)
 {
        LWDEBUGF(2, "lwgeom_clone called with %p, %s",
-               lwgeom, lwgeom_typename(TYPE_GETTYPE(lwgeom->type)));
+               lwgeom, lwtype_name(TYPE_GETTYPE(lwgeom->type)));
 
        switch (TYPE_GETTYPE(lwgeom->type))
        {
@@ -502,84 +519,11 @@ lwgeom_clone(const LWGEOM *lwgeom)
        }
 }
 
-/**
- * Add 'what' to 'to' at position 'where'
- *
- * @param where =0 == prepend if -1 == append
- *
- * Appended-to LWGEOM gets a new type based on new condition.
- * Mix of dimensions is not allowed.
- * @todo TODO: allow mix of dimensions?
- */
-LWGEOM *
-lwgeom_add(const LWGEOM *to, uint32 where, const LWGEOM *what)
-{
-       if ( TYPE_NDIMS(what->type) != TYPE_NDIMS(to->type) )
-       {
-               lwerror("lwgeom_add: mixed dimensions not supported");
-               return NULL;
-       }
-
-       LWDEBUGF(2, "lwgeom_add(%s, %d, %s) called",
-                lwgeom_typename(TYPE_GETTYPE(to->type)),
-                where,
-                lwgeom_typename(TYPE_GETTYPE(what->type)));
-
-       switch (TYPE_GETTYPE(to->type))
-       {
-       case POINTTYPE:
-               return (LWGEOM *)lwpoint_add((const LWPOINT *)to, where, what);
-       case LINETYPE:
-               return (LWGEOM *)lwline_add((const LWLINE *)to, where, what);
-
-       case CIRCSTRINGTYPE:
-               return (LWGEOM *)lwcircstring_add((const LWCIRCSTRING *)to, where, what);
-
-       case POLYGONTYPE:
-               return (LWGEOM *)lwpoly_add((const LWPOLY *)to, where, what);
-
-       case COMPOUNDTYPE:
-               return (LWGEOM *)lwcompound_add((const LWCOMPOUND *)to, where, what);
-
-       case CURVEPOLYTYPE:
-               return (LWGEOM *)lwcurvepoly_add((const LWCURVEPOLY *)to, where, what);
-
-       case MULTIPOINTTYPE:
-               return (LWGEOM *)lwmpoint_add((const LWMPOINT *)to,
-                                             where, what);
-
-       case MULTILINETYPE:
-               return (LWGEOM *)lwmline_add((const LWMLINE *)to,
-                                            where, what);
-
-       case MULTICURVETYPE:
-               return (LWGEOM *)lwmcurve_add((const LWMCURVE *)to,
-                                             where, what);
-
-       case MULTIPOLYGONTYPE:
-               return (LWGEOM *)lwmpoly_add((const LWMPOLY *)to,
-                                            where, what);
-
-       case MULTISURFACETYPE:
-               return (LWGEOM *)lwmsurface_add((const LWMSURFACE *)to,
-                                               where, what);
-
-       case COLLECTIONTYPE:
-               return (LWGEOM *)lwcollection_add(
-                          (const LWCOLLECTION *)to, where, what);
-
-       default:
-               lwerror("lwgeom_add: unknown geometry type: %s",
-                       lwgeom_typename(TYPE_GETTYPE(to->type)));
-               return NULL;
-       }
-}
-
 
 /**
  * Return an alloced string
  */
-char *
+char*
 lwgeom_to_ewkt(LWGEOM *lwgeom, int flags)
 {
        LWGEOM_UNPARSER_RESULT lwg_unparser_result;
@@ -600,8 +544,8 @@ lwgeom_to_ewkt(LWGEOM *lwgeom, int flags)
 /**
  * Return an alloced string
  */
-char *
-lwgeom_to_hexwkb(LWGEOM *lwgeom, int flags, unsigned int byteorder)
+char*
+lwgeom_to_hexwkb(LWGEOM *lwgeom, int flags, uint32 byteorder)
 {
        LWGEOM_UNPARSER_RESULT lwg_unparser_result;
        uchar *serialized = lwgeom_serialize(lwgeom);
@@ -641,7 +585,7 @@ lwgeom_to_ewkb(LWGEOM *lwgeom, int flags, char byteorder, size_t *outsize)
  *     - construct PG_LWGEOM
  *     - deserialize it
  */
-LWGEOM *
+LWGEOM*
 lwgeom_from_ewkb(uchar *ewkb, int flags, size_t size)
 {
        size_t hexewkblen = size*2;
@@ -673,7 +617,7 @@ lwgeom_from_ewkb(uchar *ewkb, int flags, size_t size)
 /**
  * Make an LWGEOM object from a EWKT representation.
  */
-LWGEOM *
+LWGEOM*
 lwgeom_from_ewkt(char *ewkt, int flags)
 {
        int result;
@@ -743,7 +687,7 @@ serialized_lwgeom_from_hexwkb(LWGEOM_PARSER_RESULT *lwg_parser_result, char *hex
  * Return an alloced string
  */
 int
-serialized_lwgeom_to_hexwkb(LWGEOM_UNPARSER_RESULT *lwg_unparser_result, uchar *serialized, int flags, unsigned int byteorder)
+serialized_lwgeom_to_hexwkb(LWGEOM_UNPARSER_RESULT *lwg_unparser_result, uchar *serialized, int flags, uint32 byteorder)
 {
        int result;
 
@@ -756,7 +700,7 @@ serialized_lwgeom_to_hexwkb(LWGEOM_UNPARSER_RESULT *lwg_unparser_result, uchar *
  * Return an alloced string
  */
 int
-serialized_lwgeom_to_ewkb(LWGEOM_UNPARSER_RESULT *lwg_unparser_result, uchar *serialized, int flags, unsigned int byteorder)
+serialized_lwgeom_to_ewkb(LWGEOM_UNPARSER_RESULT *lwg_unparser_result, uchar *serialized, int flags, uint32 byteorder)
 {
        int result;
 
@@ -779,8 +723,8 @@ char
 lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
 {
        LWDEBUGF(2, "lwgeom_same(%s, %s) called",
-                lwgeom_typename(TYPE_GETTYPE(lwgeom1->type)),
-                lwgeom_typename(TYPE_GETTYPE(lwgeom2->type)));
+                lwtype_name(TYPE_GETTYPE(lwgeom1->type)),
+                lwtype_name(TYPE_GETTYPE(lwgeom2->type)));
 
        if ( TYPE_GETTYPE(lwgeom1->type) != TYPE_GETTYPE(lwgeom2->type) )
        {
@@ -828,7 +772,7 @@ lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
                                         (LWCOLLECTION *)lwgeom2);
        default:
                lwerror("lwgeom_same: unsupported geometry type: %s",
-                       lwgeom_typename(TYPE_GETTYPE(lwgeom1->type)));
+                       lwtype_name(TYPE_GETTYPE(lwgeom1->type)));
                return LW_FALSE;
        }
 
@@ -926,7 +870,7 @@ lwgeom_longitude_shift(LWGEOM *lwgeom)
                return;
        default:
                lwerror("lwgeom_longitude_shift: unsupported geom type: %s",
-                       lwgeom_typename(TYPE_GETTYPE(lwgeom->type)));
+                       lwtype_name(TYPE_GETTYPE(lwgeom->type)));
        }
 }
 
@@ -944,11 +888,11 @@ lwgeom_is_collection(int type)
        case COMPOUNDTYPE:
        case MULTICURVETYPE:
        case MULTISURFACETYPE:
-               return -1;
+               return LW_TRUE;
                break;
 
        default:
-               return 0;
+               return LW_FALSE;
        }
 }
 
@@ -1039,11 +983,11 @@ static int lwpoint_count_vertices(LWPOINT *point)
        return 1;
 }
 
-int lwgeom_count_vertices(LWGEOM *geom)
+int lwgeom_count_vertices(const LWGEOM *geom)
 {
        int result = 0;
        LWDEBUGF(4, "lwgeom_count_vertices got type %s",
-               lwgeom_typename(TYPE_GETTYPE(geom->type)));
+               lwtype_name(TYPE_GETTYPE(geom->type)));
 
        switch (TYPE_GETTYPE(geom->type))
        {
@@ -1064,7 +1008,7 @@ int lwgeom_count_vertices(LWGEOM *geom)
                break;
        default:
                lwerror("lwgeom_count_vertices: unsupported input geometry type: %s",
-                       lwgeom_typename(TYPE_GETTYPE(geom->type)));
+                       lwtype_name(TYPE_GETTYPE(geom->type)));
                break;
        }
        LWDEBUGF(3, "counted %d vertices", result);
@@ -1110,7 +1054,7 @@ int lwgeom_is_empty(const LWGEOM *geom)
 {
        int result = LW_FALSE;
        LWDEBUGF(4, "lwgeom_is_empty: got type %s",
-               lwgeom_typename(TYPE_GETTYPE(geom->type)));
+               lwtype_name(TYPE_GETTYPE(geom->type)));
 
        switch (TYPE_GETTYPE(geom->type))
        {
@@ -1137,7 +1081,7 @@ int lwgeom_is_empty(const LWGEOM *geom)
                break;
        default:
                lwerror("lwgeom_is_empty: unsupported input geometry type: %s",
-                       lwgeom_typename(TYPE_GETTYPE(geom->type)));
+                       lwtype_name(TYPE_GETTYPE(geom->type)));
                break;
        }
        return result;
@@ -1168,7 +1112,7 @@ static int lwcollection_dimensionality(LWCOLLECTION *col)
 extern int lwgeom_dimensionality(LWGEOM *geom)
 {
        LWDEBUGF(3, "lwgeom_dimensionality got type %s",
-               lwgeom_typename(TYPE_GETTYPE(geom->type)));
+               lwtype_name(TYPE_GETTYPE(geom->type)));
 
        switch (TYPE_GETTYPE(geom->type))
        {
@@ -1194,7 +1138,7 @@ extern int lwgeom_dimensionality(LWGEOM *geom)
                break;
        default:
                lwerror("lwgeom_dimensionality: unsupported input geometry type: %s",
-                       lwgeom_typename(TYPE_GETTYPE(geom->type)));
+                       lwtype_name(TYPE_GETTYPE(geom->type)));
                break;
        }
        return 0;
@@ -1203,7 +1147,7 @@ extern int lwgeom_dimensionality(LWGEOM *geom)
 extern LWGEOM* lwgeom_remove_repeated_points(LWGEOM *in)
 {
        LWDEBUGF(4, "lwgeom_remove_repeated_points got type %s",
-               lwgeom_typename(TYPE_GETTYPE(in->type)));
+               lwtype_name(TYPE_GETTYPE(in->type)));
 
        switch (TYPE_GETTYPE(in->type))
        {
@@ -1236,7 +1180,7 @@ extern LWGEOM* lwgeom_remove_repeated_points(LWGEOM *in)
 
        default:
                lwnotice("lwgeom_remove_repeated_points: unsupported geometry type: %s",
-                       lwgeom_typename(TYPE_GETTYPE(in->type)));
+                       lwtype_name(TYPE_GETTYPE(in->type)));
                return in;
                break;
        }
@@ -1250,7 +1194,7 @@ extern LWGEOM* lwgeom_flip_coordinates(LWGEOM *in)
        int i;
 
        LWDEBUGF(3, "lwgeom_flip_coordinates: unsupported type: %s",
-               lwgeom_typename(TYPE_GETTYPE(in->type)));
+               lwtype_name(TYPE_GETTYPE(in->type)));
 
        switch (TYPE_GETTYPE(in->type))
        {
@@ -1287,7 +1231,7 @@ extern LWGEOM* lwgeom_flip_coordinates(LWGEOM *in)
 
        default:
                lwerror("lwgeom_flip_coordinates: unsupported geometry type: %s",
-                       lwgeom_typename(TYPE_GETTYPE(in->type)));
+                       lwtype_name(TYPE_GETTYPE(in->type)));
        }
        return NULL;
 }
index ce8c38a0cf08bb140d265a60ea3aa87cca4489dd..72589fc728cd37f03cfab4f3613bc966131ec0d1 100644 (file)
  *  handles the funny differences in float4 and float8 reps.
  **********************************************************************/
 
-
-/*
- * These are taken from glibc
- * some machines do *not* have these functions defined, so we give
- *  an implementation of them here.
- */
-typedef int int32_tt;
-typedef unsigned int u_int32_tt;
-
 typedef union
 {
        float value;
-       u_int32_tt word;
+       uint32 word;
 } ieee_float_shape_type;
 
 #define GET_FLOAT_WORD(i,d)                    \
@@ -57,10 +48,10 @@ typedef union
  * Returns the next smaller or next larger float
  * from x (in direction of y).
  */
-float
+static float
 nextafterf_custom(float x, float y)
 {
-       int32_tt hx,hy,ix,iy;
+       int hx,hy,ix,iy;
 
        GET_FLOAT_WORD(hx,x);
        GET_FLOAT_WORD(hy,y);
@@ -125,7 +116,7 @@ nextafterf_custom(float x, float y)
 }
 
 
-float nextDown_f(double d)
+float next_float_down(double d)
 {
        float result  = d;
 
@@ -141,7 +132,7 @@ float nextDown_f(double d)
  * handles the funny differences in float4 and float8 reps.
  */
 float
-nextUp_f(double d)
+next_float_up(double d)
 {
        float result  = d;
 
@@ -157,7 +148,7 @@ nextUp_f(double d)
  * handles the funny differences in float4 and float8 reps.
  */
 double
-nextDown_d(float d)
+next_double_down(float d)
 {
        double result  = d;
 
@@ -172,7 +163,7 @@ nextDown_d(float d)
  * handles the funny differences in float4 and float8 reps.
  */
 double
-nextUp_d(float d)
+next_double_up(float d)
 {
        double result  = d;
 
@@ -201,11 +192,11 @@ box3d_to_box2df(BOX3D *box)
        }
 #endif
 
-       result->xmin = nextDown_f(box->xmin);
-       result->ymin = nextDown_f(box->ymin);
+       result->xmin = next_float_down(box->xmin);
+       result->ymin = next_float_down(box->ymin);
 
-       result->xmax = nextUp_f(box->xmax);
-       result->ymax = nextUp_f(box->ymax);
+       result->xmax = next_float_up(box->xmax);
+       result->ymax = next_float_up(box->ymax);
 
        return result;
 }
@@ -226,11 +217,11 @@ box3d_to_box2df_p(BOX3D *box, BOX2DFLOAT4 *result)
        }
 #endif
 
-       result->xmin = nextDown_f(box->xmin);
-       result->ymin = nextDown_f(box->ymin);
+       result->xmin = next_float_down(box->xmin);
+       result->ymin = next_float_down(box->ymin);
 
-       result->xmax = nextUp_f(box->xmax);
-       result->ymax = nextUp_f(box->ymax);
+       result->xmax = next_float_up(box->xmax);
+       result->ymax = next_float_up(box->ymax);
 
        return 1;
 }
@@ -899,7 +890,7 @@ lwgeom_hasBBOX(uchar type)
  * Basic sub-geometry types
  *****************************************************************************/
 
-/* handle missaligned unsigned int32 data */
+/* handle missaligned uint3232 data */
 uint32
 lw_get_uint32(const uchar *loc)
 {
@@ -1902,7 +1893,7 @@ printMULTI(uchar *serialized)
 void
 printType(uchar type)
 {
-       lwnotice("type 0x%x ==> hasBBOX=%i, hasSRID=%i, ndims=%i, type=%i",(unsigned int) type, lwgeom_hasBBOX(type), lwgeom_hasSRID(type),lwgeom_ndims(type), lwgeom_getType(type));
+       lwnotice("type 0x%x ==> hasBBOX=%i, hasSRID=%i, ndims=%i, type=%i",(uint32) type, lwgeom_hasBBOX(type), lwgeom_hasSRID(type),lwgeom_ndims(type), lwgeom_getType(type));
 }
 
 /**
index c13c7217b18303e8d26ee424e30c76f36b2161ed..31e550c1f8e0aa27647f80b29494e4c4cc3ff74b 100644 (file)
@@ -46,10 +46,10 @@ uchar* output_multipoint(uchar* geom,int suppress);
 uchar* output_compound(uchar* geom, int suppress);
 uchar* output_multisurface(uchar* geom, int suppress);
 
-void write_wkb_hex_bytes(uchar* ptr, unsigned int cnt, size_t size);
-void write_wkb_bin_bytes(uchar* ptr, unsigned int cnt, size_t size);
-void write_wkb_bin_flip_bytes(uchar* ptr, unsigned int cnt, size_t size);
-void write_wkb_hex_flip_bytes(uchar* ptr, unsigned int cnt, size_t size);
+void write_wkb_hex_bytes(uchar* ptr, uint32 cnt, size_t size);
+void write_wkb_bin_bytes(uchar* ptr, uint32 cnt, size_t size);
+void write_wkb_bin_flip_bytes(uchar* ptr, uint32 cnt, size_t size);
+void write_wkb_hex_flip_bytes(uchar* ptr, uint32 cnt, size_t size);
 
 void write_wkb_int(int i);
 uchar* output_wkb_collection(uchar* geom,outwkbfunc func);
@@ -71,7 +71,7 @@ static char*  out_pos;
 static int len;
 static int lwgi;
 static uchar endianbyte;
-void (*write_wkb_bytes)(uchar* ptr,unsigned int cnt,size_t size);
+void (*write_wkb_bytes)(uchar* ptr,uint32 cnt,size_t size);
 
 /*
  * Unparser current instance check flags - a bitmap of flags that determine which checks are enabled during the current unparse
@@ -453,7 +453,7 @@ uchar *output_wkt(uchar* geom, int supress);
 /* special case for multipoint to supress extra brackets */
 uchar *output_multipoint(uchar* geom,int suppress)
 {
-       unsigned char type = *geom & 0x0f;
+       uchar type = *geom & 0x0f;
 
        if ( type  == POINTTYPE )
                return output_point(++geom,suppress);
@@ -472,7 +472,7 @@ uchar *output_multipoint(uchar* geom,int suppress)
    a component of a COMPOUNDCURVE, but not CIRCULARSTRING */
 uchar *output_compound(uchar* geom, int suppress)
 {
-       unsigned char type;
+       uchar type;
 
        LWDEBUG(2, "output_compound called.");
 
@@ -520,7 +520,7 @@ uchar *output_curvepoly(uchar* geom, int supress)
    a component of a MULTISURFACE, but not CURVEPOLYGON */
 uchar *output_multisurface(uchar* geom, int suppress)
 {
-       unsigned char type;
+       uchar type;
 
        LWDEBUG(2, "output_multisurface called.");
 
@@ -546,7 +546,7 @@ uchar *
 output_wkt(uchar* geom, int supress)
 {
 
-       unsigned char type=*geom++;
+       uchar type=*geom++;
        char writeM=0;
        dims = TYPE_NDIMS(type); /* ((type & 0x30) >> 4)+2; */
 
@@ -740,9 +740,9 @@ static char outchr[]=
 
 /* Write HEX bytes flipping */
 void
-write_wkb_hex_flip_bytes(uchar* ptr, unsigned int cnt, size_t size)
+write_wkb_hex_flip_bytes(uchar* ptr, uint32 cnt, size_t size)
 {
-       unsigned int bc; /* byte count */
+       uint32 bc; /* byte count */
 
        ensure(cnt*2*size);
 
@@ -759,9 +759,9 @@ write_wkb_hex_flip_bytes(uchar* ptr, unsigned int cnt, size_t size)
 
 /* Write HEX bytes w/out flipping */
 void
-write_wkb_hex_bytes(uchar* ptr, unsigned int cnt, size_t size)
+write_wkb_hex_bytes(uchar* ptr, uint32 cnt, size_t size)
 {
-       unsigned int bc; /* byte count */
+       uint32 bc; /* byte count */
 
        ensure(cnt*2*size);
 
@@ -778,9 +778,9 @@ write_wkb_hex_bytes(uchar* ptr, unsigned int cnt, size_t size)
 
 /* Write BIN bytes flipping */
 void
-write_wkb_bin_flip_bytes(uchar* ptr, unsigned int cnt, size_t size)
+write_wkb_bin_flip_bytes(uchar* ptr, uint32 cnt, size_t size)
 {
-       unsigned int bc; /* byte count */
+       uint32 bc; /* byte count */
 
        ensure(cnt*size);
 
@@ -795,9 +795,9 @@ write_wkb_bin_flip_bytes(uchar* ptr, unsigned int cnt, size_t size)
 
 /* Write BIN bytes w/out flipping */
 void
-write_wkb_bin_bytes(uchar* ptr, unsigned int cnt, size_t size)
+write_wkb_bin_bytes(uchar* ptr, uint32 cnt, size_t size)
 {
-       unsigned int bc; /* byte count */
+       uint32 bc; /* byte count */
 
        ensure(cnt*size);
 
@@ -967,7 +967,7 @@ output_wkb_circstring_collection(uchar* geom,outwkbfunc func)
 uchar *
 output_wkb(uchar* geom)
 {
-       unsigned char type=*geom++;
+       uchar type=*geom++;
        int4 wkbtype;
 
        dims = TYPE_NDIMS(type);
index c1406d2fb0743927383b4925b47167fd3b5ff123..598c0b3c4d48d6dd071f1b81537c63147fdfedc0 100644 (file)
@@ -37,7 +37,7 @@ LWGEOM *
 lwgeom_homogenize(const LWGEOM *geom)
 {
        LWGEOM *hgeom;
-       unsigned int type=TYPE_GETTYPE(geom->type);
+       uint32 type=TYPE_GETTYPE(geom->type);
 
        /* EMPTY Geometry */
        if (lwgeom_is_empty(geom)) return lwgeom_clone(geom);
@@ -62,7 +62,7 @@ lwgeom_homogenize(const LWGEOM *geom)
                if (((LWCOLLECTION *) geom)->ngeoms == 1)
                {
 
-                       hgeom =lwgeom_clone((LWGEOM *)
+                       hgeom = lwgeom_clone((LWGEOM *)
                                            ((LWCOLLECTION *)geom)->geoms[0]);
 
                        hgeom->SRID = geom->SRID;
@@ -80,7 +80,7 @@ lwgeom_homogenize(const LWGEOM *geom)
                return lwcollection_homogenize((LWCOLLECTION *) geom);
 
        lwerror("lwgeom_homogenize: Geometry Type not supported (%i)",
-               lwgeom_typename(type));
+               lwtype_name(type));
 
        return NULL; /*Never reach */
 }
@@ -102,7 +102,7 @@ lwgeom_homogenize(const LWGEOM *geom)
 LWGEOM *
 lwcollection_homogenize(const LWCOLLECTION *col)
 {
-       unsigned int i;
+       uint32 i, srid;
        uchar hasz, hasm;
        LWGEOM *res = NULL;
        LWCOLLECTION *coll;
@@ -116,15 +116,15 @@ lwcollection_homogenize(const LWCOLLECTION *col)
 
        hasz = TYPE_HASZ(col->type);
        hasm = TYPE_HASM(col->type);
+       srid = col->SRID;
 
        /* LWGEOM_HOMOGENIZE struct setup */
        geoms = lwalloc(sizeof(LWGEOM_HOMOGENIZE));
-       geoms->points = (LWMPOINT *)
-                       lwcollection_construct_empty(col->SRID, hasz, hasm);
-       geoms->lines  = (LWMLINE *)
-                       lwcollection_construct_empty(col->SRID, hasz, hasm);
-       geoms->polys  = (LWMPOLY *)
-                       lwcollection_construct_empty(col->SRID, hasz, hasm);
+       geoms->points = lwmpoint_construct_empty(-1, hasz, hasm);
+       geoms->lines = lwmline_construct_empty(-1, hasz, hasm);
+       geoms->polys = lwmpoly_construct_empty(-1, hasz, hasm);
+
+       LWDEBUGF(4, "geoms->points %p", geoms->points);
 
        /* Parse each sub geom and update LWGEOM_HOMOGENIZE struct */
        for (i=0 ; i < col->ngeoms ; i++)
@@ -132,39 +132,46 @@ lwcollection_homogenize(const LWCOLLECTION *col)
 
        /* Check if struct is mixed typed, and need a COLLECTION as output */
        if ((geoms->points->ngeoms && geoms->lines->ngeoms) ||
-               (geoms->points->ngeoms && geoms->polys->ngeoms) ||
-               (geoms->lines->ngeoms  && geoms->polys->ngeoms))
+           (geoms->points->ngeoms && geoms->polys->ngeoms) ||
+           (geoms->lines->ngeoms  && geoms->polys->ngeoms))
        {
+               LWDEBUGF(4,"geoms->points->ngeoms %d  geoms->lines->ngeoms %d  geoms->polys->ngeoms %d", geoms->points->ngeoms, geoms->lines->ngeoms, geoms->polys->ngeoms);
+               coll = lwcollection_construct_empty(srid, hasz, hasm);
+
+               LWDEBUGF(4,"coll->ngeoms %d", coll->ngeoms);
 
-               coll = lwcollection_construct_empty(col->SRID, hasz, hasm);
                if (col->bbox) coll->bbox = box2d_clone(col->bbox);
 
                if (geoms->points->ngeoms == 1)
-                       coll = (LWCOLLECTION *) lwcollection_add(coll, -1,
-                               (LWGEOM *) geoms->points->geoms[0]);
+                       coll = lwcollection_add_lwgeom(coll, lwgeom_clone((LWGEOM*) geoms->points->geoms[0]));
                else if (geoms->points->ngeoms)
-                       coll = (LWCOLLECTION *) lwcollection_add(coll, -1,
-                               (LWGEOM *) geoms->points);
+                       coll = lwcollection_add_lwgeom(coll, lwgeom_clone((LWGEOM*) geoms->points));
+
+               LWDEBUGF(4,"coll->ngeoms %d", coll->ngeoms);
 
                if (geoms->lines->ngeoms == 1)
-                       coll = (LWCOLLECTION *) lwcollection_add(coll, -1,
-                               (LWGEOM *) geoms->lines->geoms[0]);
+                       coll = lwcollection_add_lwgeom(coll, lwgeom_clone((LWGEOM*) geoms->lines->geoms[0]));
                else if (geoms->lines->ngeoms)
-                       coll = (LWCOLLECTION *) lwcollection_add(coll, -1,
-                               (LWGEOM *) geoms->lines);
+                       coll = lwcollection_add_lwgeom(coll, lwgeom_clone((LWGEOM*) geoms->lines));
+
+               LWDEBUGF(4,"coll->ngeoms %d", coll->ngeoms);
 
                if (geoms->polys->ngeoms == 1)
-                       coll = (LWCOLLECTION *) lwcollection_add(coll, -1,
-                               (LWGEOM *) geoms->polys->geoms[0]);
+                       coll = lwcollection_add_lwgeom(coll, lwgeom_clone((LWGEOM*) geoms->polys->geoms[0]));
                else if (geoms->polys->ngeoms)
-                       coll = (LWCOLLECTION *) lwcollection_add(coll, -1,
-                               (LWGEOM *) geoms->polys);
+                       coll = lwcollection_add_lwgeom(coll, lwgeom_clone((LWGEOM*) geoms->polys));
+
+               LWDEBUGF(4,"coll->ngeoms %d", coll->ngeoms);
 
                /* We could now free the struct */
                lwmpoint_release(geoms->points);
                lwmline_release(geoms->lines);
                lwmpoly_release(geoms->polys);
                lwfree(geoms);
+               
+               for( i = 0; i < coll->ngeoms; i++ )
+                       LWDEBUGF(2,"TYPE_GETTYPE(coll->geoms[%d]->type) %d", i, TYPE_GETTYPE(coll->geoms[i]->type));
+                       
 
                return (LWGEOM *) coll;
        }
@@ -195,69 +202,46 @@ lwcollection_homogenize(const LWCOLLECTION *col)
        if (!res) return (LWGEOM *) lwcollection_construct_empty(col->SRID, 0, 0);
 
        /* Handle SRID and Bbox */
-       res->SRID = col->SRID;
+       res->SRID = srid;
        if (col->bbox) res->bbox = box2d_clone(col->bbox);
 
        return res;
 }
 
-
-static LWGEOM_HOMOGENIZE *
+static LWGEOM_HOMOGENIZE*
 lwcollection_homogenize_subgeom(LWGEOM_HOMOGENIZE *hgeoms, LWGEOM *geom)
 {
-       unsigned int i, type;
+       uint32 i, type;
 
        if (!geom) lwerror("lwcollection_homogenize: Sub geometry is Null");
 
        type = TYPE_GETTYPE(geom->type);
+       
+       /* We manage the SRID in lwcollection_homogenize */
+       geom->SRID = -1;
 
        if (type == POINTTYPE)
        {
-               hgeoms->points = (LWMPOINT *) lwmpoint_add(hgeoms->points, -1, geom);
-
+               hgeoms->points = lwmpoint_add_lwpoint(hgeoms->points, (LWPOINT*)lwgeom_clone(geom));
        }
        else if (type == LINETYPE)
        {
-               hgeoms->lines = (LWMLINE *) lwmline_add(hgeoms->lines, -1, geom);
-
+               hgeoms->lines = lwmline_add_lwline(hgeoms->lines, (LWLINE*)lwgeom_clone(geom));
        }
        else if (type == POLYGONTYPE)
        {
-               hgeoms->polys = (LWMPOLY *) lwmpoly_add(hgeoms->polys, -1, geom);
-
+               hgeoms->polys = lwmpoly_add_lwpoly(hgeoms->polys, (LWPOLY*)lwgeom_clone(geom));
        }
-       else if (type == MULTIPOINTTYPE)
+       else if ( lwgeom_is_collection(type) )
        {
-               for (i=0 ; i < ((LWMPOINT *) geom)->ngeoms ; i++)
-                       hgeoms->points = (LWMPOINT *) lwmpoint_add(
-                                            hgeoms->points, -1,
-                                            (LWGEOM *) ((LWMPOINT *)geom)->geoms[i]);
-
-       }
-       else if (type == MULTILINETYPE)
-       {
-               for (i=0 ; i < ((LWMLINE *) geom)->ngeoms ; i++)
-                       hgeoms->lines = (LWMLINE *) lwmline_add(
-                                           hgeoms->lines, -1,
-                                           (LWGEOM *) ((LWMLINE *)geom)->geoms[i]);
-
+               LWCOLLECTION *obj = (LWCOLLECTION*)geom;
+               for (i=0; i < obj->ngeoms ; i++)
+                       hgeoms = lwcollection_homogenize_subgeom(hgeoms, obj->geoms[i]);
        }
-       else if (type == MULTIPOLYGONTYPE)
+       else 
        {
-               for (i=0 ; i < ((LWMPOLY *) geom)->ngeoms ; i++)
-                       hgeoms->polys = (LWMPOLY *) lwmpoly_add(
-                                           hgeoms->polys, -1,
-                                           (LWGEOM *) ((LWMPOLY *)geom)->geoms[i]);
-
-       }
-       else if (type == COLLECTIONTYPE)
-       {
-               for (i=0; i < ((LWCOLLECTION *) geom)->ngeoms ; i++)
-                       hgeoms = lwcollection_homogenize_subgeom(hgeoms,
-                                ((LWCOLLECTION *) geom)->geoms[i]);
-
+               lwerror("lwcollection_homogenize: Unsupported geometry type");
        }
-       else lwerror("lwcollection_homogenize: Unsupported geometry type");
 
        return hgeoms;
 }
index 95650aecf54cc6a584693874bc4f90dd107adebf..fad8826cf6c86f39335edeff6acdaf5807cc0a7e 100644 (file)
@@ -46,6 +46,18 @@ lwline_construct(int SRID, BOX2DFLOAT4 *bbox, POINTARRAY *points)
        return result;
 }
 
+LWLINE *
+lwline_construct_empty(int srid, char hasz, char hasm)
+{
+       LWLINE *result = lwalloc(sizeof(LWLINE));
+       result->type = lwgeom_makeType_full(hasz, hasm, (srid>0), LINETYPE, 0);
+       result->SRID = srid;
+       result->points = NULL;
+       result->bbox = NULL;
+       return result;
+}
+
+
 /*
  * given the LWGEOM serialized form (or a pointer into a muli* one)
  * construct a proper LWLINE.
@@ -65,7 +77,7 @@ lwline_deserialize(uchar *serialized_form)
 
        if ( lwgeom_getType(type) != LINETYPE)
        {
-               lwerror("lwline_deserialize: attempt to deserialize a line which is really a %s", lwgeom_typename(type));
+               lwerror("lwline_deserialize: attempt to deserialize a line which is really a %s", lwtype_name(type));
                return NULL;
        }
 
@@ -301,7 +313,7 @@ void printLWLINE(LWLINE *line)
 }
 
 int
-lwline_compute_box2d_p(LWLINE *line, BOX2DFLOAT4 *box)
+lwline_compute_box2d_p(const LWLINE *line, BOX2DFLOAT4 *box)
 {
        return ptarray_compute_box2d_p(line->points, box);
 }
@@ -319,57 +331,6 @@ lwline_clone(const LWLINE *g)
        return ret;
 }
 
-/*
- * Add 'what' to this line at position 'where'.
- * where=0 == prepend
- * where=-1 == append
- * Returns a MULTILINE or a GEOMETRYCOLLECTION
- */
-LWGEOM *
-lwline_add(const LWLINE *to, uint32 where, const LWGEOM *what)
-{
-       LWCOLLECTION *col;
-       LWGEOM **geoms;
-       int newtype;
-
-       if ( where != -1 && where != 0 )
-       {
-               lwerror("lwline_add only supports 0 or -1 as second argument, got %d", where);
-               return NULL;
-       }
-
-       /* dimensions compatibility are checked by caller */
-
-       /* Construct geoms array */
-       geoms = lwalloc(sizeof(LWGEOM *)*2);
-       if ( where == -1 ) /* append */
-       {
-               geoms[0] = lwgeom_clone((LWGEOM *)to);
-               geoms[1] = lwgeom_clone(what);
-       }
-       else /* prepend */
-       {
-               geoms[0] = lwgeom_clone(what);
-               geoms[1] = lwgeom_clone((LWGEOM *)to);
-       }
-
-       /* reset SRID and wantbbox flag from component types */
-       geoms[0]->SRID = geoms[1]->SRID = -1;
-       TYPE_SETHASSRID(geoms[0]->type, 0);
-       TYPE_SETHASSRID(geoms[1]->type, 0);
-       TYPE_SETHASBBOX(geoms[0]->type, 0);
-       TYPE_SETHASBBOX(geoms[1]->type, 0);
-
-       /* Find appropriate geom type */
-       if ( TYPE_GETTYPE(what->type) == LINETYPE ) newtype = MULTILINETYPE;
-       else newtype = COLLECTIONTYPE;
-
-       col = lwcollection_construct(newtype,
-                                    to->SRID, NULL,
-                                    2, geoms);
-
-       return (LWGEOM *)col;
-}
 
 void
 lwline_release(LWLINE *lwline)
@@ -402,10 +363,10 @@ lwline_same(const LWLINE *l1, const LWLINE *l2)
  * LWLINE dimensions are large enough to host all input dimensions.
  */
 LWLINE *
-lwline_from_lwpointarray(int SRID, unsigned int npoints, LWPOINT **points)
+lwline_from_lwpointarray(int SRID, uint32 npoints, LWPOINT **points)
 {
        int zmflag=0;
-       unsigned int i;
+       uint32 i;
        POINTARRAY *pa;
        uchar *newpoints, *ptr;
        size_t ptsize, size;
@@ -418,7 +379,7 @@ lwline_from_lwpointarray(int SRID, unsigned int npoints, LWPOINT **points)
                if ( TYPE_GETTYPE(points[i]->type) != POINTTYPE )
                {
                        lwerror("lwline_from_lwpointarray: invalid input type: %s",
-                               lwgeom_typename(TYPE_GETTYPE(points[i]->type)));
+                               lwtype_name(TYPE_GETTYPE(points[i]->type)));
                        return NULL;
                }
                if ( TYPE_HASZ(points[i]->type) ) zmflag |= 2;
@@ -456,7 +417,7 @@ lwline_from_lwpointarray(int SRID, unsigned int npoints, LWPOINT **points)
 LWLINE *
 lwline_from_lwmpoint(int SRID, LWMPOINT *mpoint)
 {
-       unsigned int i;
+       uint32 i;
        POINTARRAY *pa;
        char zmflag = TYPE_GETZM(mpoint->type);
        size_t ptsize, size;
@@ -489,7 +450,7 @@ lwline_from_lwmpoint(int SRID, LWMPOINT *mpoint)
 }
 
 LWLINE *
-lwline_addpoint(LWLINE *line, LWPOINT *point, unsigned int where)
+lwline_addpoint(LWLINE *line, LWPOINT *point, uint32 where)
 {
        POINTARRAY *newpa;
        LWLINE *ret;
@@ -506,7 +467,7 @@ lwline_addpoint(LWLINE *line, LWPOINT *point, unsigned int where)
 }
 
 LWLINE *
-lwline_removepoint(LWLINE *line, unsigned int index)
+lwline_removepoint(LWLINE *line, uint32 index)
 {
        POINTARRAY *newpa;
        LWLINE *ret;
@@ -522,7 +483,7 @@ lwline_removepoint(LWLINE *line, unsigned int index)
  * Note: input will be changed, make sure you have permissions for this.
  */
 void
-lwline_setPoint4d(LWLINE *line, unsigned int index, POINT4D *newpoint)
+lwline_setPoint4d(LWLINE *line, uint32 index, POINT4D *newpoint)
 {
        setPoint4d(line->points, index, newpoint);
        /* Update the box, if there is one to update */
index 981bb4cb856e6960ee9cca8843d56060602ed070..2257724bb05e09017682d23feb96e75094635be4 100644 (file)
@@ -90,49 +90,5 @@ lwmcurve_deserialize(uchar *srl)
        return result;
 }
 
-/*
- * Add 'what' to this multicurve at position 'where'.
- * where=0 == prepend
- * where=-1 == append
- * Returns a MULTICURVE or a COLLECTION
- */
-LWGEOM *
-lwmcurve_add(const LWMCURVE *to, uint32 where, const LWGEOM *what)
-{
-       LWCOLLECTION *col;
-       LWGEOM **geoms;
-       int newtype;
-       uint32 i;
-
-       if (where == -1) where = to->ngeoms;
-       else if (where < -1 || where > to->ngeoms)
-       {
-               lwerror("lwmcurve_add: add position out of range %d..%d",
-                       -1, to->ngeoms);
-               return NULL;
-       }
-
-       /* dimensions compatibility are checked by caller */
-
-       /* Construct geoms array */
-       geoms = lwalloc(sizeof(LWGEOM *)*(to->ngeoms+1));
-       for (i = 0; i < where; i++)
-       {
-               geoms[i] = lwgeom_clone((LWGEOM *)to->geoms[i]);
-       }
-       geoms[where] = lwgeom_clone(what);
-       for (i = where; i < to->ngeoms; i++)
-       {
-               geoms[i+1] = lwgeom_clone((LWGEOM *)to->geoms[i]);
-       }
 
-       if (TYPE_GETTYPE(what->type) == CIRCSTRINGTYPE) newtype = MULTICURVETYPE;
-       else newtype = COLLECTIONTYPE;
-
-       col = lwcollection_construct(newtype,
-                                    to->SRID, NULL,
-                                    to->ngeoms + 1, geoms);
-
-       return (LWGEOM *)col;
-}
 
index dd23290e25682b91b262d74b09e6f11a58603189..29b58d37a2753b24603c9697e23788ccae60944f 100644 (file)
@@ -21,6 +21,14 @@ lwmline_release(LWMLINE *lwmline)
        lwgeom_release(lwmline_as_lwgeom(lwmline));
 }
 
+LWMLINE *
+lwmline_construct_empty(int srid, char hasz, char hasm)
+{
+       LWMLINE *ret = (LWMLINE*)lwcollection_construct_empty(srid, hasz, hasm);
+       TYPE_SETTYPE(ret->type, MULTILINETYPE);
+       return ret;
+}
+
 LWMLINE *
 lwmline_deserialize(uchar *srl)
 {
@@ -76,51 +84,9 @@ lwmline_deserialize(uchar *srl)
        return result;
 }
 
-/*
- * Add 'what' to this multiline at position 'where'.
- * where=0 == prepend
- * where=-1 == append
- * Returns a MULTILINE or a COLLECTION
- */
-LWGEOM *
-lwmline_add(const LWMLINE *to, uint32 where, const LWGEOM *what)
+LWMLINE* lwmline_add_lwline(LWMLINE *mobj, const LWLINE *obj)
 {
-       LWCOLLECTION *col;
-       LWGEOM **geoms;
-       int newtype;
-       uint32 i;
-
-       if ( where == -1 ) where = to->ngeoms;
-       else if ( where < -1 || where > to->ngeoms )
-       {
-               lwerror("lwmline_add: add position out of range %d..%d",
-                       -1, to->ngeoms);
-               return NULL;
-       }
-
-       /* dimensions compatibility are checked by caller */
-
-       /* Construct geoms array */
-       geoms = lwalloc(sizeof(LWGEOM *)*(to->ngeoms+1));
-       for (i=0; i<where; i++)
-       {
-               geoms[i] = lwgeom_clone((LWGEOM *)to->geoms[i]);
-       }
-       geoms[where] = lwgeom_clone(what);
-       for (i=where; i<to->ngeoms; i++)
-       {
-               geoms[i+1] = lwgeom_clone((LWGEOM *)to->geoms[i]);
-       }
-
-       if ( TYPE_GETTYPE(what->type) == LINETYPE ) newtype = MULTILINETYPE;
-       else newtype = COLLECTIONTYPE;
-
-       col = lwcollection_construct(newtype,
-                                    to->SRID, NULL,
-                                    to->ngeoms+1, geoms);
-
-       return (LWGEOM *)col;
-
+       return (LWMLINE*)lwcollection_add_lwgeom((LWCOLLECTION*)mobj, (LWGEOM*)obj);
 }
 
 /**
index 7960d90b44b28d7c02bde44c00a55001f6c73d68..a143c841395d0908108389cb03a257e6bba00b39 100644 (file)
@@ -21,6 +21,13 @@ lwmpoint_release(LWMPOINT *lwmpoint)
        lwgeom_release(lwmpoint_as_lwgeom(lwmpoint));
 }
 
+LWMPOINT *
+lwmpoint_construct_empty(int srid, char hasz, char hasm)
+{
+       LWMPOINT *ret = (LWMPOINT*)lwcollection_construct_empty(srid, hasz, hasm);
+       TYPE_SETTYPE(ret->type, MULTIPOINTTYPE);
+       return ret;
+}
 
 LWMPOINT *
 lwmpoint_deserialize(uchar *srl)
@@ -79,51 +86,10 @@ lwmpoint_deserialize(uchar *srl)
        return result;
 }
 
-/*
- * Add 'what' to this multipoint at position 'where'.
- * where=0 == prepend
- * where=-1 == append
- * Returns a MULTIPOINT or a COLLECTION
- */
-LWGEOM *
-lwmpoint_add(const LWMPOINT *to, uint32 where, const LWGEOM *what)
+LWMPOINT* lwmpoint_add_lwpoint(LWMPOINT *mobj, const LWPOINT *obj)
 {
-       LWCOLLECTION *col;
-       LWGEOM **geoms;
-       int newtype;
-       uint32 i;
-
-       if ( where == -1 ) where = to->ngeoms;
-       else if ( where < -1 || where > to->ngeoms )
-       {
-               lwerror("lwmpoint_add: add position out of range %d..%d",
-                       -1, to->ngeoms);
-               return NULL;
-       }
-
-       /* dimensions compatibility are checked by caller */
-
-       /* Construct geoms array */
-       geoms = lwalloc(sizeof(LWGEOM *)*(to->ngeoms+1));
-       for (i=0; i<where; i++)
-       {
-               geoms[i] = lwgeom_clone((LWGEOM *)to->geoms[i]);
-       }
-       geoms[where] = lwgeom_clone(what);
-       for (i=where; i<to->ngeoms; i++)
-       {
-               geoms[i+1] = lwgeom_clone((LWGEOM *)to->geoms[i]);
-       }
-
-       if ( TYPE_GETTYPE(what->type) == POINTTYPE ) newtype = MULTIPOINTTYPE;
-       else newtype = COLLECTIONTYPE;
-
-       col = lwcollection_construct(newtype,
-                                    to->SRID, NULL,
-                                    to->ngeoms+1, geoms);
-
-       return (LWGEOM *)col;
-
+       LWDEBUG(4, "Called");
+       return (LWMPOINT*)lwcollection_add_lwgeom((LWCOLLECTION*)mobj, (LWGEOM*)obj);
 }
 
 void lwmpoint_free(LWMPOINT *mpt)
@@ -151,8 +117,8 @@ void lwmpoint_free(LWMPOINT *mpt)
 LWGEOM*
 lwmpoint_remove_repeated_points(LWMPOINT *mpoint)
 {
-       unsigned int nnewgeoms;
-       unsigned int i, j;
+       uint32 nnewgeoms;
+       uint32 i, j;
        LWGEOM **newgeoms;
 
        newgeoms = lwalloc(sizeof(LWGEOM *)*mpoint->ngeoms);
index 7b07b45b4e17a61976b07895dfc09816396e01f6..18cb6c3b9f6b6dac57cade0a627bc3a5a65c0b66 100644 (file)
@@ -22,6 +22,13 @@ lwmpoly_release(LWMPOLY *lwmpoly)
        lwgeom_release(lwmpoly_as_lwgeom(lwmpoly));
 }
 
+LWMPOLY *
+lwmpoly_construct_empty(int srid, char hasz, char hasm)
+{
+       LWMPOLY *ret = (LWMPOLY*)lwcollection_construct_empty(srid, hasz, hasm);
+       TYPE_SETTYPE(ret->type, MULTIPOLYGONTYPE);
+       return ret;
+}
 
 LWMPOLY *
 lwmpoly_deserialize(uchar *srl)
@@ -79,52 +86,12 @@ lwmpoly_deserialize(uchar *srl)
        return result;
 }
 
-/**
- * Add 'what' to this multiline at position 'where'.
- * @param where if 0 == prepend, if = -1 then append
- * @return a {@link #MULTIPOLY} or a {@link #COLLECTION}
- */
-LWGEOM *
-lwmpoly_add(const LWMPOLY *to, uint32 where, const LWGEOM *what)
+LWMPOLY* lwmpoly_add_lwpoly(LWMPOLY *mobj, const LWPOLY *obj)
 {
-       LWCOLLECTION *col;
-       LWGEOM **geoms;
-       int newtype;
-       uint32 i;
-
-       if ( where == -1 ) where = to->ngeoms;
-       else if ( where < -1 || where > to->ngeoms )
-       {
-               lwerror("lwmline_add: add position out of range %d..%d",
-                       -1, to->ngeoms);
-               return NULL;
-       }
-
-       /* dimensions compatibility are checked by caller */
-
-       /* Construct geoms array */
-       geoms = lwalloc(sizeof(LWGEOM *)*(to->ngeoms+1));
-       for (i=0; i<where; i++)
-       {
-               geoms[i] = lwgeom_clone((LWGEOM *)to->geoms[i]);
-       }
-       geoms[where] = lwgeom_clone(what);
-       for (i=where; i<to->ngeoms; i++)
-       {
-               geoms[i+1] = lwgeom_clone((LWGEOM *)to->geoms[i]);
-       }
-
-       if ( TYPE_GETTYPE(what->type) == POLYGONTYPE ) newtype = MULTIPOLYGONTYPE;
-       else newtype = COLLECTIONTYPE;
-
-       col = lwcollection_construct(newtype,
-                                    to->SRID, NULL,
-                                    to->ngeoms+1, geoms);
-
-       return (LWGEOM *)col;
-
+       return (LWMPOLY*)lwcollection_add_lwgeom((LWCOLLECTION*)mobj, (LWGEOM*)obj);
 }
 
+
 void lwmpoly_free(LWMPOLY *mpoly)
 {
        int i;
index c343d01e8673b666000e80316540278d5b5e1ac7..f203a515c92ac53409ec13d598cee6f749f4ddf8 100644 (file)
@@ -88,50 +88,4 @@ lwmsurface_deserialize(uchar *srl)
        return result;
 }
 
-/*
- * Add 'what' to this multisurface at position 'where'
- * where=0 == prepend
- * where=-1 == append
- * Returns a MULTISURFACE or a COLLECTION
- */
-LWGEOM *
-lwmsurface_add(const LWMSURFACE *to, uint32 where, const LWGEOM *what)
-{
-       LWCOLLECTION *col;
-       LWGEOM **geoms;
-       int newtype;
-       uint32 i;
-
-       if (where == -1) where = to->ngeoms;
-       else if (where < -1 || where > to->ngeoms)
-       {
-               lwerror("lwmsurface_add: add position out of range %d..%d",
-                       -1, to->ngeoms);
-               return NULL;
-       }
-
-       /* dimensions compatibility are checked by caller */
-
-       /* Construct geoms array */
-       geoms = lwalloc(sizeof(LWGEOM *)*(to->ngeoms+1));
-       for (i = 0; i < where; i++)
-       {
-               geoms[i] = lwgeom_clone((LWGEOM *)to->geoms[i]);
-       }
-       geoms[where] = lwgeom_clone(what);
-       for (i = where; i < to->ngeoms; i++)
-       {
-               geoms[i+1] = lwgeom_clone((LWGEOM *)to->geoms[i]);
-       }
-
-       if (TYPE_GETTYPE(what->type) == POLYGONTYPE ||
-               TYPE_GETTYPE(what->type) == CURVEPOLYTYPE)
-               newtype = MULTISURFACETYPE;
-       else newtype = COLLECTIONTYPE;
-
-       col = lwcollection_construct(newtype,
-                                    to->SRID, NULL, to->ngeoms + 1, geoms);
-
-       return (LWGEOM *)col;
-}
 
index 7944f2cef475ad8307c387a00d975722bbdf9c20..954dffc4f091a82fae7854bb54a02a799e21aefc 100644 (file)
@@ -90,7 +90,7 @@ lwgeom_to_geojson(uchar *geom, char *srs, int precision, int has_bbox)
                        bbox = NULL;
                }
                lwerror("lwgeom_to_geojson: '%s' geometry type not supported",
-                       lwgeom_typename(type));
+                       lwtype_name(type));
        }
 
        if (bbox)
index 42507e97dcb2c856277d21e4f9aa0ac93ac08021..168276fd86f048ad5a03d1788e606e343c764a7d 100644 (file)
@@ -91,7 +91,7 @@ lwgeom_to_gml2(uchar *geom, char *srs, int precision)
 
        default:
                lwerror("lwgeom_to_gml2: '%s' geometry type not supported",
-                       lwgeom_typename(type));
+                       lwtype_name(type));
                return NULL;
        }
 }
@@ -597,7 +597,7 @@ lwgeom_to_gml3(uchar *geom, char *srs, int precision, int is_deegree)
                return asgml3_collection(inspected, srs, precision, is_deegree);
 
        default:
-               lwerror("lwgeom_to_gml3: '%s' geometry type not supported", lwgeom_typename(type));
+               lwerror("lwgeom_to_gml3: '%s' geometry type not supported", lwtype_name(type));
                return NULL;
        }
 }
index dcb9aa0da21f0e0901c6703d9e5d5eee98494343..c5e841e8e398913581728ccbcb3f16006e831d60 100644 (file)
@@ -75,7 +75,7 @@ lwgeom_to_kml2(uchar *geom, int precision)
 
        default:
                lwerror("lwgeom_to_kml2: '%s' geometry type not supported",
-                       lwgeom_typename(type));
+                       lwtype_name(type));
                return NULL;
        }
 }
index 535ebbf34c13087aca34e061ab59261bcaac68ab..9786fc215b001efe1cb3c14f7c13ec41fa22665b 100644 (file)
@@ -74,7 +74,7 @@ lwgeom_to_svg(uchar *geom, int precision, int relative)
 
        default:
                lwerror("lwgeom_to_svg: '%s' geometry type not supported",
-                       lwgeom_typename(type));
+                       lwtype_name(type));
        }
 
        return ret;
@@ -512,7 +512,7 @@ assvg_inspected_buf(LWGEOM_INSPECTED *insp, char *output, int relative, int prec
 
        default:
                lwerror("ST_AsSVG: '%s' geometry type not supported.",
-                       lwgeom_typename(type));
+                       lwtype_name(type));
        }
 
        return (ptr-output);
index 0b72b720440ef620c2f08b479cb8a6d844fb0abb..51cfe5f8c344bfc8bbdc1f44e273c89ac5b42279 100644 (file)
 static char* lwgeom_to_wkb_buf(const LWGEOM *geom, char *buf, uchar variant);
 static size_t lwgeom_to_wkb_size(const LWGEOM *geom, uchar variant);
 
-#define WKB_DOUBLE_SIZE 8
-#define WKB_INT_SIZE 4
-#define WKB_BYTE_SIZE 1
-
 /*
 * Look-up table for hex writer
 */
@@ -37,9 +33,9 @@ static int lwgeom_wkb_needs_srid(const LWGEOM *geom, uchar variant)
 /*
 * GeometryType
 */
-static unsigned int lwgeom_wkb_type(const LWGEOM *geom, uchar variant)
+static uint32 lwgeom_wkb_type(const LWGEOM *geom, uchar variant)
 {
-       unsigned int wkb_type = 0;
+       uint32 wkb_type = 0;
 
        uchar type = geom->type;
        
@@ -82,7 +78,7 @@ static unsigned int lwgeom_wkb_type(const LWGEOM *geom, uchar variant)
                        wkb_type = 12;
                        break;
                default:
-                       lwerror("Unsupported geometry type: %s [%d]", lwgeom_typename(type), type);
+                       lwerror("Unsupported geometry type: %s [%d]", lwtype_name(type), type);
        }
        
        if( variant & WKB_EXTENDED )
@@ -128,7 +124,7 @@ static char* endian_to_wkb_buf(char *buf, uchar variant)
 /*
 * SwapBytes?
 */
-static int wkb_swap_bytes(uchar variant)
+static inline int wkb_swap_bytes(uchar variant)
 {
        /* If requested variant matches machine arch, we don't have to swap! */
        if( ((variant & WKB_NDR) && (BYTE_ORDER == LITTLE_ENDIAN)) ||
@@ -142,7 +138,7 @@ static int wkb_swap_bytes(uchar variant)
 /*
 * Integer32
 */
-static char* int32_to_wkb_buf(const int ival, char *buf, uchar variant)
+static char* integer_to_wkb_buf(const int ival, char *buf, uchar variant)
 {
        char *iptr = (char*)(&ival);
        int i = 0;
@@ -154,7 +150,7 @@ static char* int32_to_wkb_buf(const int ival, char *buf, uchar variant)
        LWDEBUGF(4, "Writing value '%u'", ival);
        if( variant & WKB_HEX )
        {
-               int swap =  wkb_swap_bytes(variant);
+               int swap = wkb_swap_bytes(variant);
                /* Machine/request arch mismatch, so flip byte order */
                for( i = 0; i < WKB_INT_SIZE; i++ )
                {
@@ -249,7 +245,7 @@ static size_t empty_to_wkb_size(const LWGEOM *geom, uchar variant)
 
 static char* empty_to_wkb_buf(const LWGEOM *geom, char *buf, uchar variant)
 {
-       unsigned int wkb_type = lwgeom_wkb_type(geom, variant);
+       uint32 wkb_type = lwgeom_wkb_type(geom, variant);
 
        if( TYPE_GETTYPE(geom->type) == POINTTYPE )
                wkb_type += 3; /* Change POINT to MULTIPOINT */
@@ -258,14 +254,14 @@ static char* empty_to_wkb_buf(const LWGEOM *geom, char *buf, uchar variant)
        buf = endian_to_wkb_buf(buf, variant);
 
        /* Set the geometry type */
-       buf = int32_to_wkb_buf(wkb_type, buf, variant);
+       buf = integer_to_wkb_buf(wkb_type, buf, variant);
 
        /* Set the SRID if necessary */
        if( lwgeom_wkb_needs_srid(geom, variant) )
-               buf = int32_to_wkb_buf(geom->SRID, buf, variant);
+               buf = integer_to_wkb_buf(geom->SRID, buf, variant);
 
        /* Set nrings/npoints/ngeoms to zero */
-       buf = int32_to_wkb_buf(0, buf, variant);
+       buf = integer_to_wkb_buf(0, buf, variant);
        return buf;
 }
 
@@ -310,7 +306,7 @@ static char* ptarray_to_wkb_buf(const POINTARRAY *pa, char *buf, uchar variant)
 
        /* Set the number of points (if it's not a POINT type) */
        if( ! ( variant & WKB_NO_NPOINTS ) )
-               buf = int32_to_wkb_buf(pa->npoints, buf, variant);
+               buf = integer_to_wkb_buf(pa->npoints, buf, variant);
        
        /* Set the ordinates. */
        /* TODO: Ensure that getPoint_internal is always aligned so 
@@ -355,12 +351,12 @@ static char* lwpoint_to_wkb_buf(const LWPOINT *pt, char *buf, uchar variant)
        buf = endian_to_wkb_buf(buf, variant);
        LWDEBUGF(4, "Endian set, buf = %p", buf);
        /* Set the geometry type */
-       buf = int32_to_wkb_buf(lwgeom_wkb_type((LWGEOM*)pt, variant), buf, variant);
+       buf = integer_to_wkb_buf(lwgeom_wkb_type((LWGEOM*)pt, variant), buf, variant);
        LWDEBUGF(4, "Type set, buf = %p", buf);
        /* Set the optional SRID for extended variant */
        if ( lwgeom_wkb_needs_srid((LWGEOM*)pt, variant) )
        {
-               buf = int32_to_wkb_buf(pt->SRID, buf, variant);
+               buf = integer_to_wkb_buf(pt->SRID, buf, variant);
                LWDEBUGF(4, "SRID set, buf = %p", buf);
        }
        /* Set the coordinates */
@@ -391,10 +387,10 @@ static char* lwline_to_wkb_buf(const LWLINE *line, char *buf, uchar variant)
        /* Set the endian flag */
        buf = endian_to_wkb_buf(buf, variant);
        /* Set the geometry type */
-       buf = int32_to_wkb_buf(lwgeom_wkb_type((LWGEOM*)line, variant), buf, variant);
+       buf = integer_to_wkb_buf(lwgeom_wkb_type((LWGEOM*)line, variant), buf, variant);
        /* Set the optional SRID for extended variant */
        if ( lwgeom_wkb_needs_srid((LWGEOM*)line, variant) )
-               buf = int32_to_wkb_buf(line->SRID, buf, variant);
+               buf = integer_to_wkb_buf(line->SRID, buf, variant);
        /* Set the coordinates */
        buf = ptarray_to_wkb_buf(line->points, buf, variant);
        return buf;
@@ -429,12 +425,12 @@ static char* lwpoly_to_wkb_buf(const LWPOLY *poly, char *buf, uchar variant)
        /* Set the endian flag */
        buf = endian_to_wkb_buf(buf, variant);
        /* Set the geometry type */
-       buf = int32_to_wkb_buf(lwgeom_wkb_type((LWGEOM*)poly, variant), buf, variant);
+       buf = integer_to_wkb_buf(lwgeom_wkb_type((LWGEOM*)poly, variant), buf, variant);
        /* Set the optional SRID for extended variant */
        if ( lwgeom_wkb_needs_srid((LWGEOM*)poly, variant) )
-               buf = int32_to_wkb_buf(poly->SRID, buf, variant);
+               buf = integer_to_wkb_buf(poly->SRID, buf, variant);
        /* Set the number of rings */
-       buf = int32_to_wkb_buf(poly->nrings, buf, variant);
+       buf = integer_to_wkb_buf(poly->nrings, buf, variant);
        
        for( i = 0; i < poly->nrings; i++ )
        {
@@ -474,12 +470,12 @@ static char* lwcollection_to_wkb_buf(const LWCOLLECTION *col, char *buf, uchar v
        /* Set the endian flag */
        buf = endian_to_wkb_buf(buf, variant);
        /* Set the geometry type */
-       buf = int32_to_wkb_buf(lwgeom_wkb_type((LWGEOM*)col, variant), buf, variant);
+       buf = integer_to_wkb_buf(lwgeom_wkb_type((LWGEOM*)col, variant), buf, variant);
        /* Set the optional SRID for extended variant */
        if ( lwgeom_wkb_needs_srid((LWGEOM*)col, variant) )
-               buf = int32_to_wkb_buf(col->SRID, buf, variant);
+               buf = integer_to_wkb_buf(col->SRID, buf, variant);
        /* Set the number of sub-geometries */
-       buf = int32_to_wkb_buf(col->ngeoms, buf, variant);
+       buf = integer_to_wkb_buf(col->ngeoms, buf, variant);
        
        for( i = 0; i < col->ngeoms; i++ )
        {
@@ -536,7 +532,7 @@ static size_t lwgeom_to_wkb_size(const LWGEOM *geom, uchar variant)
 
                /* Unknown type! */
                default:
-                       lwerror("Unsupported geometry type: %s [%d]", lwgeom_typename(geom->type), TYPE_GETTYPE(geom->type));
+                       lwerror("Unsupported geometry type: %s [%d]", lwtype_name(geom->type), TYPE_GETTYPE(geom->type));
        }
 
        return size;
@@ -575,7 +571,7 @@ static char* lwgeom_to_wkb_buf(const LWGEOM *geom, char *buf, uchar variant)
 
                /* Unknown type! */
                default:
-                       lwerror("Unsupported geometry type: %s [%d]", lwgeom_typename(geom->type), TYPE_GETTYPE(geom->type));
+                       lwerror("Unsupported geometry type: %s [%d]", lwtype_name(geom->type), TYPE_GETTYPE(geom->type));
        }
        /* Return value to keep compiler happy. */
        return 0;
index 64a77ce0d79e9fe229876b28403c98d75ae8780a..8eba163675929ab95a5018e54868bcf297ec7085 100644 (file)
@@ -261,7 +261,7 @@ lwpoint_deserialize(uchar *serialized_form)
 
        if ( geom_type != POINTTYPE)
        {
-               lwerror("lwpoint_deserialize: attempt to deserialize a point which is really a %s", lwgeom_typename(geom_type));
+               lwerror("lwpoint_deserialize: attempt to deserialize a point which is really a %s", lwtype_name(geom_type));
                return NULL;
        }
        result->type = type;
@@ -320,7 +320,7 @@ void printLWPOINT(LWPOINT *point)
 }
 
 int
-lwpoint_compute_box2d_p(LWPOINT *point, BOX2DFLOAT4 *box)
+lwpoint_compute_box2d_p(const LWPOINT *point, BOX2DFLOAT4 *box)
 {
        return ptarray_compute_box2d_p(point->point, box);
 }
@@ -338,56 +338,6 @@ lwpoint_clone(const LWPOINT *g)
        return ret;
 }
 
-/*
- * Add 'what' to this point at position 'where'.
- * where=0 == prepend
- * where=-1 == append
- * Returns a MULTIPOINT or a GEOMETRYCOLLECTION
- */
-LWGEOM *
-lwpoint_add(const LWPOINT *to, uint32 where, const LWGEOM *what)
-{
-       LWCOLLECTION *col;
-       LWGEOM **geoms;
-       int newtype;
-
-       if ( where != -1 && where != 0 )
-       {
-               lwerror("lwpoint_add only supports 0 or -1 as second argument, got %d", where);
-               return NULL;
-       }
-
-       /* dimensions compatibility are checked by caller */
-
-
-       /* Construct geoms array */
-       geoms = lwalloc(sizeof(LWGEOM *)*2);
-       if ( where == -1 ) /* append */
-       {
-               geoms[0] = lwgeom_clone((LWGEOM *)to);
-               geoms[1] = lwgeom_clone(what);
-       }
-       else /* prepend */
-       {
-               geoms[0] = lwgeom_clone(what);
-               geoms[1] = lwgeom_clone((LWGEOM *)to);
-       }
-       /* reset SRID and wantbbox flag from component types */
-       lwgeom_dropSRID(geoms[0]);
-       lwgeom_drop_bbox(geoms[0]);
-       lwgeom_dropSRID(geoms[1]);
-       lwgeom_drop_bbox(geoms[1]);
-
-       /* Find appropriate geom type */
-       if ( TYPE_GETTYPE(what->type) == POINTTYPE ) newtype = MULTIPOINTTYPE;
-       else newtype = COLLECTIONTYPE;
-
-       col = lwcollection_construct(newtype,
-                                    to->SRID, NULL,
-                                    2, geoms);
-
-       return (LWGEOM *)col;
-}
 
 /* Find length of this serialized point */
 size_t
index 34c680418d375ce0657954dc133b92627c34f32d..222c90f987852869513b3cf8d843cf2a26002bcd 100644 (file)
 /* construct a new LWPOLY.  arrays (points/points per ring) will NOT be copied
  * use SRID=-1 for unknown SRID (will have 8bit type's S = 0)
  */
-LWPOLY *
-lwpoly_construct(int SRID, BOX2DFLOAT4 *bbox, unsigned int nrings, POINTARRAY **points)
+LWPOLY*
+lwpoly_construct(int SRID, BOX2DFLOAT4 *bbox, uint32 nrings, POINTARRAY **points)
 {
        LWPOLY *result;
        int hasz, hasm;
 #ifdef CHECK_POLY_RINGS_ZM
        char zm;
-       unsigned int i;
+       uint32 i;
 #endif
 
        if ( nrings < 1 ) lwerror("lwpoly_construct: need at least 1 ring");
@@ -58,6 +58,19 @@ lwpoly_construct(int SRID, BOX2DFLOAT4 *bbox, unsigned int nrings, POINTARRAY **
        return result;
 }
 
+LWPOLY*
+lwpoly_construct_empty(int srid, char hasz, char hasm)
+{
+       LWPOLY *result = lwalloc(sizeof(LWPOLY));
+       result->type = lwgeom_makeType_full(hasz, hasm, (srid>0), POLYGONTYPE, 0);
+       result->SRID = srid;
+       result->nrings = 0;
+       result->maxrings = 0;
+       result->rings = NULL;
+       result->bbox = NULL;
+       return result;
+}
+
 
 /*
  * given the LWPOLY serialized form (or a pointer into a muli* one)
@@ -95,7 +108,7 @@ lwpoly_deserialize(uchar *serialized_form)
 
        if ( TYPE_GETTYPE(type) != POLYGONTYPE)
        {
-               lwerror("lwpoly_deserialize: attempt to deserialize a poly which is really a %s", lwgeom_typename(type));
+               lwerror("lwpoly_deserialize: attempt to deserialize a poly which is really a %s", lwtype_name(type));
                return NULL;
        }
 
@@ -403,7 +416,7 @@ void printLWPOLY(LWPOLY *poly)
 }
 
 int
-lwpoly_compute_box2d_p(LWPOLY *poly, BOX2DFLOAT4 *box)
+lwpoly_compute_box2d_p(const LWPOLY *poly, BOX2DFLOAT4 *box)
 {
        BOX2DFLOAT4 boxbuf;
        uint32 i;
@@ -432,57 +445,6 @@ lwpoly_clone(const LWPOLY *g)
        return ret;
 }
 
-/*
- * Add 'what' to this poly at position 'where'.
- * where=0 == prepend
- * where=-1 == append
- * Returns a MULTIPOLYGON or a GEOMETRYCOLLECTION
- */
-LWGEOM *
-lwpoly_add(const LWPOLY *to, uint32 where, const LWGEOM *what)
-{
-       LWCOLLECTION *col;
-       LWGEOM **geoms;
-       int newtype;
-
-       if ( where != -1 && where != 0 )
-       {
-               lwerror("lwpoly_add only supports 0 or -1 as second argument, got %d", where);
-               return NULL;
-       }
-
-       /* dimensions compatibility are checked by caller */
-
-       /* Construct geoms array */
-       geoms = lwalloc(sizeof(LWGEOM *)*2);
-       if ( where == -1 ) /* append */
-       {
-               geoms[0] = lwgeom_clone((LWGEOM *)to);
-               geoms[1] = lwgeom_clone(what);
-       }
-       else /* prepend */
-       {
-               geoms[0] = lwgeom_clone(what);
-               geoms[1] = lwgeom_clone((LWGEOM *)to);
-       }
-
-       /* reset SRID and wantbbox flag from component types */
-       geoms[0]->SRID = geoms[1]->SRID = -1;
-       TYPE_SETHASSRID(geoms[0]->type, 0);
-       TYPE_SETHASSRID(geoms[1]->type, 0);
-       TYPE_SETHASBBOX(geoms[0]->type, 0);
-       TYPE_SETHASBBOX(geoms[1]->type, 0);
-
-       /* Find appropriate geom type */
-       if ( TYPE_GETTYPE(what->type) == POLYGONTYPE ) newtype = MULTIPOLYGONTYPE;
-       else newtype = COLLECTIONTYPE;
-
-       col = lwcollection_construct(newtype,
-                                    to->SRID, NULL,
-                                    2, geoms);
-
-       return (LWGEOM *)col;
-}
 
 void
 lwpoly_forceRHR(LWPOLY *poly)
@@ -522,7 +484,7 @@ LWPOLY *
 lwpoly_segmentize2d(LWPOLY *poly, double dist)
 {
        POINTARRAY **newrings;
-       unsigned int i;
+       uint32 i;
 
        newrings = lwalloc(sizeof(POINTARRAY *)*poly->nrings);
        for (i=0; i<poly->nrings; i++)
@@ -540,7 +502,7 @@ lwpoly_segmentize2d(LWPOLY *poly, double dist)
 char
 lwpoly_same(const LWPOLY *p1, const LWPOLY *p2)
 {
-       unsigned int i;
+       uint32 i;
 
        if ( p1->nrings != p2->nrings ) return 0;
        for (i=0; i<p1->nrings; i++)
@@ -560,9 +522,9 @@ lwpoly_same(const LWPOLY *p1, const LWPOLY *p2)
  */
 LWPOLY *
 lwpoly_from_lwlines(const LWLINE *shell,
-                    unsigned int nholes, const LWLINE **holes)
+                    uint32 nholes, const LWLINE **holes)
 {
-       unsigned int nrings;
+       uint32 nrings;
        POINTARRAY **rings = lwalloc((nholes+1)*sizeof(POINTARRAY *));
        int SRID = shell->SRID;
        LWPOLY *ret;
@@ -595,7 +557,7 @@ lwpoly_from_lwlines(const LWLINE *shell,
 LWGEOM*
 lwpoly_remove_repeated_points(LWPOLY *poly)
 {
-       unsigned int i;
+       uint32 i;
        POINTARRAY **newrings;
 
        newrings = lwalloc(sizeof(POINTARRAY *)*poly->nrings);
index 032401f356df7009fbe684e6df7c39f5b08835cc..2c3cb225d2e41e87bf81dc1b5d409dc1642ce4b4 100644 (file)
@@ -384,7 +384,7 @@ static char * lwdoubles_to_latlon(double lat, double lon, const char * format)
  * First normalizes the values so they will display as -90 to 90 and -180 to 180.
  * Format string may be null or 0-length, in which case a default format will be used.
  * NOTE: Format string is required to be in UTF-8. */
-char * lwpoint_to_latlon(LWPOINT * pt, const char * format)
+char* lwpoint_to_latlon(const LWPOINT * pt, const char *format)
 {
        POINT2D p;
        if (NULL == pt)
index 596a6675f8b1e4698af8c4248b5c5f4d091686b4..d8159fd20c4317adde2682a99a06672a9067aa89 100644 (file)
@@ -46,8 +46,8 @@ LWGEOM *lwgeom_desegmentize(LWGEOM *geom);
  * Determines (recursively in the case of collections) whether the geometry
  * contains at least on arc geometry or segment.
  */
-uint32
-has_arc(LWGEOM *geom)
+int
+has_arc(const LWGEOM *geom)
 {
        LWCOLLECTION *col;
        int i;
@@ -152,7 +152,7 @@ lwcircle_segmentize(POINT4D *p1, POINT4D *p2, POINT4D *p3, uint32 perQuad)
        POINTARRAY *result;
        POINT4D pbuf;
        size_t ptsize = sizeof(POINT4D);
-       unsigned int ptcount;
+       uint32 ptcount;
        uchar *pt;
 
        POINT4D *center;
index e362c17d5513d8452b8936196795770327f05c29..e327b0bdaa8512df8142da9f57862ed76f735f19 100644 (file)
@@ -207,7 +207,7 @@ void lwgeom_install_default_allocators(void)
 }
 
 
-const char* lwgeom_typename(int type)
+const char* lwtype_name(int type)
 {
        /* something went wrong somewhere */
        if ( type < 0 || type > 15 )
index 47fa110e78b5066d0f97dbca8c6f0f2e98a402a5..e73f11b7715222fa52ded9bef805b6b3f6e2ae84 100644 (file)
@@ -320,7 +320,7 @@ lw_dist2d_distribute_bruteforce(LWGEOM *lwg1, LWGEOM *lwg2, DISTPTS *dl)
                }
                else
                {
-                       lwerror("Unsupported geometry type: %s", lwgeom_typename(t2));
+                       lwerror("Unsupported geometry type: %s", lwtype_name(t2));
                        return LW_FALSE;
                }
        }
@@ -344,7 +344,7 @@ lw_dist2d_distribute_bruteforce(LWGEOM *lwg1, LWGEOM *lwg2, DISTPTS *dl)
                }
                else
                {
-                       lwerror("Unsupported geometry type: %s", lwgeom_typename(t2));
+                       lwerror("Unsupported geometry type: %s", lwtype_name(t2));
                        return LW_FALSE;
                }
        }
@@ -367,13 +367,13 @@ lw_dist2d_distribute_bruteforce(LWGEOM *lwg1, LWGEOM *lwg2, DISTPTS *dl)
                }
                else
                {
-                       lwerror("Unsupported geometry type: %s", lwgeom_typename(t2));
+                       lwerror("Unsupported geometry type: %s", lwtype_name(t2));
                        return LW_FALSE;
                }
        }
        else
        {
-               lwerror("Unsupported geometry type: %s", lwgeom_typename(t1));
+               lwerror("Unsupported geometry type: %s", lwtype_name(t1));
                return LW_FALSE;
        }
        /*You shouldn't being able to get here*/
@@ -427,7 +427,7 @@ lw_dist2d_distribute_fast(LWGEOM *lwg1, LWGEOM *lwg2, DISTPTS *dl)
                pa1 = ((LWPOLY *)lwg1)->rings[0];
                break;
        default:
-               lwerror("Unsupported geometry1 type: %s", lwgeom_typename(type1));
+               lwerror("Unsupported geometry1 type: %s", lwtype_name(type1));
                return LW_FALSE;
        }
        switch (type2)
@@ -439,7 +439,7 @@ lw_dist2d_distribute_fast(LWGEOM *lwg1, LWGEOM *lwg2, DISTPTS *dl)
                pa2 = ((LWPOLY *)lwg2)->rings[0];
                break;
        default:
-               lwerror("Unsupported geometry2 type: %s", lwgeom_typename(type1));
+               lwerror("Unsupported geometry2 type: %s", lwtype_name(type1));
                return LW_FALSE;
        }
        dl->twisted=1;
@@ -1192,7 +1192,7 @@ Functions in common for Brute force and new calculation
  *
  */
 int
-pt_in_ring_2d(POINT2D *p, POINTARRAY *ring)
+pt_in_ring_2d(const POINT2D *p, const POINTARRAY *ring)
 {
        int cn = 0;    /* the crossing number counter */
        int i;
@@ -1369,7 +1369,7 @@ End of Functions in common for Brute force and new calculation
  can be affectes in the world I don't dare removing it.
  */
 int
-pt_in_poly_2d(POINT2D *p, LWPOLY *poly)
+pt_in_poly_2d(const POINT2D *p, const LWPOLY *poly)
 {
        int i;
 
@@ -1391,7 +1391,7 @@ pt_in_poly_2d(POINT2D *p, LWPOLY *poly)
 The old function nessecary for ptarray_segmentize2d in ptarray.c
 */
 double
-distance2d_pt_pt(POINT2D *p1, POINT2D *p2)
+distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
 {
        double hside = p2->x - p1->x;
        double vside = p2->y - p1->y;
@@ -1411,7 +1411,7 @@ distance2d_pt_pt(POINT2D *p1, POINT2D *p2)
 The old function nessecary for ptarray_segmentize2d in ptarray.c
 */
 double
-distance2d_pt_seg(POINT2D *p, POINT2D *A, POINT2D *B)
+distance2d_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B)
 {
        double  r,s;
 
@@ -1468,7 +1468,7 @@ distance2d_pt_seg(POINT2D *p, POINT2D *A, POINT2D *B)
 find the 2d length of the given POINTARRAY (even if it's 3d)
 */
 double
-lwgeom_pointarray_length2d(POINTARRAY *pts)
+lwgeom_pointarray_length2d(const POINTARRAY *pts)
 {
        double dist = 0.0;
        int i;
@@ -1491,7 +1491,7 @@ lwgeom_pointarray_length2d(POINTARRAY *pts)
  * (depending on its dimensions)
  */
 double
-lwgeom_pointarray_length(POINTARRAY *pts)
+lwgeom_pointarray_length(const POINTARRAY *pts)
 {
        double dist = 0.0;
        int i;
@@ -1529,7 +1529,7 @@ lwgeom_curvepolygon_area(LWCURVEPOLY *curvepoly)
  * Could use a more numerically stable calculator...
  */
 double
-lwgeom_polygon_area(LWPOLY *poly)
+lwgeom_polygon_area(const LWPOLY *poly)
 {
        double poly_area=0.0;
        int i;
@@ -1573,7 +1573,7 @@ lwgeom_polygon_area(LWPOLY *poly)
  * Could use a more numerically stable calculator...
  */
 double
-lwgeom_polygon_perimeter(LWPOLY *poly)
+lwgeom_polygon_perimeter(const LWPOLY *poly)
 {
        double result=0.0;
        int i;
@@ -1591,7 +1591,7 @@ lwgeom_polygon_perimeter(LWPOLY *poly)
  * Could use a more numerically stable calculator...
  */
 double
-lwgeom_polygon_perimeter2d(LWPOLY *poly)
+lwgeom_polygon_perimeter2d(const LWPOLY *poly)
 {
        double result=0.0;
        int i;
@@ -1623,7 +1623,7 @@ lwgeom_pt_inside_circle(POINT2D *p, double cx, double cy, double rad)
  * Return 0 on exception (same point), 1 otherwise.
  */
 int
-azimuth_pt_pt(POINT2D *A, POINT2D *B, double *d)
+azimuth_pt_pt(const POINT2D *A, const POINT2D *B, double *d)
 {
        if ( A->x == B->x )
        {
index cd0cc985fa98a557bab53098cb16f5391c2df214..01c6b98fc2e1f77db5beb9c33d2881745de13274 100644 (file)
@@ -16,8 +16,8 @@
 #include "liblwgeom.h"
 
 
-POINTARRAY *
-ptarray_construct(char hasz, char hasm, unsigned int npoints)
+POINTARRAY*
+ptarray_construct(char hasz, char hasm, uint32 npoints)
 {
        uchar dims = 0;
        size_t size;
@@ -41,6 +41,33 @@ ptarray_construct(char hasz, char hasm, unsigned int npoints)
 
 }
 
+POINTARRAY*
+ptarray_construct_copy_data(char hasz, char hasm, uint32 npoints, uchar *ptlist)
+{
+       uchar dims = 0;
+       size_t size;
+       POINTARRAY *pa = NULL;
+
+       pa = lwalloc(sizeof(POINTARRAY));
+
+       TYPE_SETZM(dims, hasz?1:0, hasm?1:0);
+       size = TYPE_NDIMS(dims)*npoints*sizeof(double);
+       pa->dims = dims;
+       pa->npoints = npoints;
+
+       if ( size )
+       {
+               pa->serialized_pointlist = (uchar *)lwalloc(size);
+               memcpy(pa->serialized_pointlist, ptlist, size);
+       }
+       else
+       {
+               pa->serialized_pointlist = NULL;
+       }
+
+       return pa;
+}
+
 void ptarray_free(POINTARRAY *pa)
 {
        /**
@@ -174,7 +201,7 @@ ptarray_compute_box2d(const POINTARRAY *pa)
  * Z and M values for added points (if needed) are set to 0.
  */
 POINTARRAY *
-ptarray_segmentize2d(POINTARRAY *ipa, double dist)
+ptarray_segmentize2d(const POINTARRAY *ipa, double dist)
 {
        double  segdist;
        POINT4D p1, p2;
@@ -252,7 +279,7 @@ ptarray_segmentize2d(POINTARRAY *ipa, double dist)
 char
 ptarray_same(const POINTARRAY *pa1, const POINTARRAY *pa2)
 {
-       unsigned int i;
+       uint32 i;
        size_t ptsize;
 
        if ( TYPE_GETZM(pa1->dims) != TYPE_GETZM(pa2->dims) ) return 0;
@@ -282,7 +309,7 @@ ptarray_same(const POINTARRAY *pa1, const POINTARRAY *pa2)
  *          for the actual points, or NULL on error.
  */
 POINTARRAY *
-ptarray_addPoint(const POINTARRAY *pa, uchar *p, size_t pdims, unsigned int where)
+ptarray_addPoint(const POINTARRAY *pa, uchar *p, size_t pdims, uint32 where)
 {
        POINTARRAY *ret;
        POINT4D pbuf;
@@ -341,7 +368,7 @@ ptarray_addPoint(const POINTARRAY *pa, uchar *p, size_t pdims, unsigned int wher
  * @return #POINTARRAY is newly allocated
  */
 POINTARRAY *
-ptarray_removePoint(POINTARRAY *pa, unsigned int which)
+ptarray_removePoint(POINTARRAY *pa, uint32 which)
 {
        POINTARRAY *ret;
        size_t ptsize = pointArray_ptsize(pa);
index 941637e38be49f909b1571b3c563b37253475b49..b8f068d8798e9f7faf392e80e666af9cf6fb1cbd 100644 (file)
@@ -42,6 +42,7 @@ typedef struct struct_lwgeom_unparser_result
 }
 LWGEOM_UNPARSER_RESULT;
 #endif
+
 typedef void* (*allocator)(size_t size);
 typedef void  (*freeor)(void* mem);
 typedef void  (*report_error)(const char* string, ...);
index aacfbe2bf51634441de576188feec016d15390d4..ccac78c74d624bc4910538eaebb09aa444c4a1bb 100644 (file)
@@ -25,7 +25,7 @@ typedef struct struct_ring
        Point *list;            /* list of points */
        struct struct_ring *next;
        int n;                  /* number of points in list */
-       unsigned int linked;    /* number of "next" rings */
+       uint32 linked;  /* number of "next" rings */
 } Ring;
 
 
index a2b6d52406277719e7fa62bc28353ca6c0dd89f5..2ab2b610e1e488292e2c1f167d3f82c1e031c36a 100644 (file)
@@ -171,7 +171,7 @@ typedef struct shp_loader_state
        char *pgtype;
 
        /* PostGIS geometry type (numeric version) */
-       unsigned int wkbtype;
+       uint32 wkbtype;
 
        /* Number of dimensions to output */
        int pgdims;
index b22f0fb21f652dd795facb7e25c5535a75c99980..dbfb0cba15aa29ab4f3b90892bf04ea47a54da25 100644 (file)
@@ -314,35 +314,35 @@ static int gidx_from_gbox_p(GBOX box, GIDX *a)
        ndims = (FLAGS_GET_GEODETIC(box.flags) ? 3 : FLAGS_NDIMS(box.flags));
        SET_VARSIZE(a, VARHDRSZ + ndims * 2 * sizeof(float));
 
-       GIDX_SET_MIN(a,0,nextDown_f(box.xmin));
-       GIDX_SET_MAX(a,0,nextUp_f(box.xmax));
-       GIDX_SET_MIN(a,1,nextDown_f(box.ymin));
-       GIDX_SET_MAX(a,1,nextUp_f(box.ymax));
+       GIDX_SET_MIN(a,0,next_float_down(box.xmin));
+       GIDX_SET_MAX(a,0,next_float_up(box.xmax));
+       GIDX_SET_MIN(a,1,next_float_down(box.ymin));
+       GIDX_SET_MAX(a,1,next_float_up(box.ymax));
 
        /* Geodetic indexes are always 3d, geocentric x/y/z */
        if ( FLAGS_GET_GEODETIC(box.flags) )
        {
-               GIDX_SET_MIN(a,2,nextDown_f(box.zmin));
-               GIDX_SET_MAX(a,2,nextUp_f(box.zmax));
+               GIDX_SET_MIN(a,2,next_float_down(box.zmin));
+               GIDX_SET_MAX(a,2,next_float_up(box.zmax));
        }
        else
        {
                /* Cartesian with Z implies Z is third dimension */
                if ( FLAGS_GET_Z(box.flags) )
                {
-                       GIDX_SET_MIN(a,2,nextDown_f(box.zmin));
-                       GIDX_SET_MAX(a,2,nextUp_f(box.zmax));
+                       GIDX_SET_MIN(a,2,next_float_down(box.zmin));
+                       GIDX_SET_MAX(a,2,next_float_up(box.zmax));
                        if ( FLAGS_GET_M(box.flags) )
                        {
-                               GIDX_SET_MIN(a,3,nextDown_f(box.mmin));
-                               GIDX_SET_MAX(a,3,nextUp_f(box.mmax));
+                               GIDX_SET_MIN(a,3,next_float_down(box.mmin));
+                               GIDX_SET_MAX(a,3,next_float_up(box.mmax));
                        }
                }
                /* Unless there's no Z, in which case M is third dimension */
                else if ( FLAGS_GET_M(box.flags) )
                {
-                       GIDX_SET_MIN(a,2,nextDown_f(box.mmin));
-                       GIDX_SET_MAX(a,2,nextUp_f(box.mmax));
+                       GIDX_SET_MIN(a,2,next_float_down(box.mmin));
+                       GIDX_SET_MAX(a,2,next_float_up(box.mmax));
                }
        }
 
index 0d647f64833734fe6bd93f26f7f46fb3ac170027..01cd5567e2cc3f48ab1827cec8077803ee60b376 100644 (file)
@@ -91,7 +91,7 @@ void geography_valid_type(uchar type)
        {
                ereport(ERROR, (
                            errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                           errmsg("Geography type does not support %s", lwgeom_typename(type) )));
+                           errmsg("Geography type does not support %s", lwtype_name(type) )));
 
        }
 }
@@ -146,7 +146,7 @@ void geography_valid_typmod(LWGEOM *lwgeom, int32 typmod)
        {
                ereport(ERROR, (
                            errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                           errmsg("Geometry type (%s) does not match column type (%s)", lwgeom_typename(lwgeom_type), lwgeom_typename(typmod_type)) ));
+                           errmsg("Geometry type (%s) does not match column type (%s)", lwtype_name(lwgeom_type), lwtype_name(typmod_type)) ));
        }
 
        /* Mismatched Z dimensionality. */
@@ -417,7 +417,7 @@ Datum geography_typmod_out(PG_FUNCTION_ARGS)
 
        /* Has type? */
        if ( type )
-               str += sprintf(str, "%s", lwgeom_typename(type));
+               str += sprintf(str, "%s", lwtype_name(type));
 
        /* Need dummy type to append Z/M to? */
        if ( !type & (hasz || hasz) )
@@ -891,7 +891,7 @@ Datum geography_typmod_type(PG_FUNCTION_ARGS)
        if ( typmod < 0 || type == 0 )
                str += sprintf(str, "Geometry");
        else
-               str += sprintf(str, "%s", lwgeom_typename(type));
+               str += sprintf(str, "%s", lwtype_name(type));
 
        /* Has Z? */
        if ( typmod >= 0 && TYPMOD_GET_Z(typmod) )
index 53216e1849412118bb7988f470990f1261d043e5..b7f2d8d135b925b8c9e075e6156ec382cf91d26a 100644 (file)
@@ -542,7 +542,7 @@ pixel_add_float32(PIXEL *where, PIXEL *what)
 void
 pixel_add_int24(PIXEL *where, PIXEL *what)
 {
-       unsigned int red, green, blue;
+       uint32 red, green, blue;
        RGB rgb1, rgb2;
 
        memcpy(&rgb1, where->val, 3);
@@ -1022,7 +1022,7 @@ chip_draw_lwgeom(CHIP *chip, LWGEOM *lwgeom, PIXEL *pixel, int op)
                return;
        case POLYGONTYPE:
                lwerror("%s geometry unsupported by draw operation",
-                       lwgeom_typename(TYPE_GETTYPE(lwgeom->type)));
+                       lwtype_name(TYPE_GETTYPE(lwgeom->type)));
        case MULTIPOINTTYPE:
        case MULTILINETYPE:
        case MULTIPOLYGONTYPE:
index e5951849ce4e9e041f96e2cba7a831bd3b3cb85e..3a7e65eedd5188f5dc46a95c1462f41d773849b8 100644 (file)
@@ -12,7 +12,7 @@ char *lwline_summary(LWLINE *line, int offset);
 char *lwpoint_summary(LWPOINT *point, int offset);
 
 char *
-lwgeom_summary(LWGEOM *lwgeom, int offset)
+lwgeom_summary(const LWGEOM *lwgeom, int offset)
 {
        char *result;
 
@@ -54,7 +54,7 @@ lwpoint_summary(LWPOINT *point, int offset)
        result = lwalloc(128+offset);
 
        sprintf(result, "%*.s%s[%s]\n",
-               offset, pad, lwgeom_typename(TYPE_GETTYPE(point->type)),
+               offset, pad, lwtype_name(TYPE_GETTYPE(point->type)),
                lwgeom_typeflags(point->type));
        return result;
 }
@@ -68,7 +68,7 @@ lwline_summary(LWLINE *line, int offset)
        result = lwalloc(128+offset);
 
        sprintf(result, "%*.s%s[%s] with %d points\n",
-               offset, pad, lwgeom_typename(TYPE_GETTYPE(line->type)),
+               offset, pad, lwtype_name(TYPE_GETTYPE(line->type)),
                lwgeom_typeflags(line->type),
                line->points->npoints);
        return result;
@@ -89,7 +89,7 @@ lwcollection_summary(LWCOLLECTION *col, int offset)
        result = (char *)lwalloc(size);
 
        sprintf(result, "%*.s%s[%s] with %d elements\n",
-               offset, pad, lwgeom_typename(TYPE_GETTYPE(col->type)),
+               offset, pad, lwtype_name(TYPE_GETTYPE(col->type)),
                lwgeom_typeflags(col->type),
                col->ngeoms);
 
@@ -124,7 +124,7 @@ lwpoly_summary(LWPOLY *poly, int offset)
        result = lwalloc(size);
 
        sprintf(result, "%*.s%s[%s] with %i rings\n",
-               offset, pad, lwgeom_typename(TYPE_GETTYPE(poly->type)),
+               offset, pad, lwtype_name(TYPE_GETTYPE(poly->type)),
                lwgeom_typeflags(poly->type),
                poly->nrings);
 
index 459654c6f186b2eca9f15df1f67c611000ca293b..f2cbcd076f3925b2d6ddd0bb98e3ea9437fc0d5b 100644 (file)
@@ -70,7 +70,7 @@ Datum LWGEOM_dump(PG_FUNCTION_ARGS)
        Datum result;
        char address[256];
        char *ptr;
-       unsigned int i;
+       uint32 i;
        char *values[2];
 
        if (SRF_IS_FIRSTCALL())
index 73c86ba74e305087922a82f3af0b461ea5639cbc..592d3b1b97413b3ee187117f0d8284cb87c32e11 100644 (file)
@@ -257,8 +257,8 @@ simplify2d_lwpoly(const LWPOLY *ipoly, double dist)
 LWCOLLECTION *
 simplify2d_collection(const LWCOLLECTION *igeom, double dist)
 {
-       unsigned int i;
-       unsigned int ngeoms=0;
+       uint32 i;
+       uint32 ngeoms=0;
        LWGEOM **geoms = lwalloc(sizeof(LWGEOM *)*igeom->ngeoms);
        LWCOLLECTION *out;
 
@@ -719,9 +719,9 @@ lwpoint_grid(LWPOINT *point, gridspec *grid)
 LWCOLLECTION *
 lwcollection_grid(LWCOLLECTION *coll, gridspec *grid)
 {
-       unsigned int i;
+       uint32 i;
        LWGEOM **geoms;
-       unsigned int ngeoms=0;
+       uint32 ngeoms=0;
 
        geoms = palloc(coll->ngeoms * sizeof(LWGEOM *));
 
@@ -755,7 +755,7 @@ lwgeom_grid(LWGEOM *lwgeom, gridspec *grid)
                return (LWGEOM *)lwcollection_grid((LWCOLLECTION *)lwgeom, grid);
        default:
                elog(ERROR, "lwgeom_grid: Unsupported geometry type: %s",
-                    lwgeom_typename(TYPE_GETTYPE(lwgeom->type)));
+                    lwtype_name(TYPE_GETTYPE(lwgeom->type)));
                return NULL;
        }
 }
@@ -798,7 +798,7 @@ Datum LWGEOM_snaptogrid(PG_FUNCTION_ARGS)
 
        in_lwgeom = lwgeom_deserialize(SERIALIZED_FORM(in_geom));
 
-       POSTGIS_DEBUGF(3, "SnapToGrid got a %s", lwgeom_typename(TYPE_GETTYPE(in_lwgeom->type)));
+       POSTGIS_DEBUGF(3, "SnapToGrid got a %s", lwtype_name(TYPE_GETTYPE(in_lwgeom->type)));
 
        out_lwgeom = lwgeom_grid(in_lwgeom, &grid);
        if ( out_lwgeom == NULL ) PG_RETURN_NULL();
@@ -834,7 +834,7 @@ Datum LWGEOM_snaptogrid(PG_FUNCTION_ARGS)
        }
 #endif /* 0 */
 
-       POSTGIS_DEBUGF(3, "SnapToGrid made a %s", lwgeom_typename(TYPE_GETTYPE(out_lwgeom->type)));
+       POSTGIS_DEBUGF(3, "SnapToGrid made a %s", lwtype_name(TYPE_GETTYPE(out_lwgeom->type)));
 
        out_geom = pglwgeom_serialize(out_lwgeom);
 
@@ -900,7 +900,7 @@ Datum LWGEOM_snaptogrid_pointoff(PG_FUNCTION_ARGS)
 
        in_lwgeom = lwgeom_deserialize(SERIALIZED_FORM(in_geom));
 
-       POSTGIS_DEBUGF(3, "SnapToGrid got a %s", lwgeom_typename(TYPE_GETTYPE(in_lwgeom->type)));
+       POSTGIS_DEBUGF(3, "SnapToGrid got a %s", lwtype_name(TYPE_GETTYPE(in_lwgeom->type)));
 
        out_lwgeom = lwgeom_grid(in_lwgeom, &grid);
        if ( out_lwgeom == NULL ) PG_RETURN_NULL();
@@ -936,7 +936,7 @@ Datum LWGEOM_snaptogrid_pointoff(PG_FUNCTION_ARGS)
        }
 #endif /* 0 */
 
-       POSTGIS_DEBUGF(3, "SnapToGrid made a %s", lwgeom_typename(TYPE_GETTYPE(out_lwgeom->type)));
+       POSTGIS_DEBUGF(3, "SnapToGrid made a %s", lwtype_name(TYPE_GETTYPE(out_lwgeom->type)));
 
        out_geom = pglwgeom_serialize(out_lwgeom);
 
index ac9102576d6ca7d75b8d41f263563a22ad6943e5..4c124758b69fbdef8aacd5484676052a352afd13 100644 (file)
@@ -662,7 +662,7 @@ lwgeom_force2d_recursive(uchar *serialized, uchar *optr, size_t *retsize)
        * first and then call us again
        */
 
-       LWDEBUGF(3, "lwgeom_force2d_recursive: it's a collection (%s)", lwgeom_typename(type));
+       LWDEBUGF(3, "lwgeom_force2d_recursive: it's a collection (%s)", lwtype_name(type));
 
 
        /* Add type */
@@ -673,7 +673,7 @@ lwgeom_force2d_recursive(uchar *serialized, uchar *optr, size_t *retsize)
        totsize++;
        loc=serialized+1;
 
-       LWDEBUGF(3, "lwgeom_force2d_recursive: added collection type (%s[%s]) - size:%d", lwgeom_typename(type), lwgeom_typeflags(newtypefl), totsize);
+       LWDEBUGF(3, "lwgeom_force2d_recursive: added collection type (%s[%s]) - size:%d", lwtype_name(type), lwgeom_typeflags(newtypefl), totsize);
 
        if ( lwgeom_hasBBOX(serialized[0]) != lwgeom_hasBBOX(newtypefl) )
                lwerror("typeflag mismatch in BBOX");
@@ -1073,7 +1073,7 @@ lwgeom_force3dm_recursive(uchar *serialized, uchar *optr, size_t *retsize)
        * first and then call us again
        */
 
-       LWDEBUGF(3, "lwgeom_force3dm_recursive: it's a collection (%s)", lwgeom_typename(type));
+       LWDEBUGF(3, "lwgeom_force3dm_recursive: it's a collection (%s)", lwtype_name(type));
 
 
        /* Add type */
@@ -1084,7 +1084,7 @@ lwgeom_force3dm_recursive(uchar *serialized, uchar *optr, size_t *retsize)
        totsize++;
        loc=serialized+1;
 
-       LWDEBUGF(3, "lwgeom_force3dm_recursive: added collection type (%s[%s]) - size:%d", lwgeom_typename(type), lwgeom_typeflags(newtypefl), totsize);
+       LWDEBUGF(3, "lwgeom_force3dm_recursive: added collection type (%s[%s]) - size:%d", lwtype_name(type), lwgeom_typeflags(newtypefl), totsize);
 
        if ( lwgeom_hasBBOX(serialized[0]) != lwgeom_hasBBOX(newtypefl) )
                lwerror("typeflag mismatch in BBOX");
@@ -1883,7 +1883,7 @@ Datum LWGEOM_collect(PG_FUNCTION_ARGS)
        Pointer geom2_ptr =  PG_GETARG_POINTER(1);
        PG_LWGEOM *pglwgeom1, *pglwgeom2, *result;
        LWGEOM *lwgeoms[2], *outlwg;
-       unsigned int type1, type2, outtype;
+       uint32 type1, type2, outtype;
        BOX2DFLOAT4 *box=NULL;
        int SRID;
 
@@ -1913,7 +1913,7 @@ Datum LWGEOM_collect(PG_FUNCTION_ARGS)
        pglwgeom1 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
        pglwgeom2 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
 
-       POSTGIS_DEBUGF(3, "LWGEOM_collect(%s, %s): call", lwgeom_typename(TYPE_GETTYPE(pglwgeom1->type)), lwgeom_typename(TYPE_GETTYPE(pglwgeom2->type)));
+       POSTGIS_DEBUGF(3, "LWGEOM_collect(%s, %s): call", lwtype_name(TYPE_GETTYPE(pglwgeom1->type)), lwtype_name(TYPE_GETTYPE(pglwgeom2->type)));
 
 #if 0
        if ( pglwgeom_getSRID(pglwgeom1) != pglwgeom_getSRID(pglwgeom2) )
@@ -2106,7 +2106,7 @@ Datum LWGEOM_collect_garray(PG_FUNCTION_ARGS)
        /*PG_LWGEOM **geoms; */
        PG_LWGEOM *result=NULL;
        LWGEOM **lwgeoms, *outlwg;
-       unsigned int outtype;
+       uint32 outtype;
        int i, count;
        int SRID=-1;
        size_t offset;
@@ -2161,7 +2161,7 @@ Datum LWGEOM_collect_garray(PG_FUNCTION_ARGS)
                if ((bitmap && (*bitmap & bitmask) != 0) || !bitmap)
                {
                        PG_LWGEOM *geom = (PG_LWGEOM *)(ARR_DATA_PTR(array)+offset);
-                       unsigned int intype = TYPE_GETTYPE(geom->type);
+                       uint32 intype = TYPE_GETTYPE(geom->type);
 
                        offset += INTALIGN(VARSIZE(geom));
 
@@ -2314,7 +2314,7 @@ Datum LWGEOM_makeline_garray(PG_FUNCTION_ARGS)
        PG_LWGEOM *result=NULL;
        LWPOINT **lwpoints;
        LWGEOM *outlwg;
-       unsigned int npoints;
+       uint32 npoints;
        int i;
        size_t offset;
        int SRID=-1;
@@ -2479,8 +2479,8 @@ Datum LWGEOM_makepoly(PG_FUNCTION_ARGS)
        const LWLINE *shell=NULL;
        const LWLINE **holes=NULL;
        LWPOLY *outpoly;
-       unsigned int nholes=0;
-       unsigned int i;
+       uint32 nholes=0;
+       uint32 i;
        size_t offset=0;
 
        POSTGIS_DEBUG(2, "LWGEOM_makepoly called.");
@@ -3093,7 +3093,7 @@ Datum LWGEOM_removepoint(PG_FUNCTION_ARGS)
 {
        PG_LWGEOM *pglwg1, *result;
        LWLINE *line, *outline;
-       unsigned int which;
+       uint32 which;
 
        POSTGIS_DEBUG(2, "LWGEOM_removepoint called.");
 
@@ -3141,7 +3141,7 @@ Datum LWGEOM_setpoint_linestring(PG_FUNCTION_ARGS)
        LWLINE *line;
        LWPOINT *lwpoint;
        POINT4D newpoint;
-       unsigned int which;
+       uint32 which;
 
        POSTGIS_DEBUG(2, "LWGEOM_setpoint_linestring called.");
 
index c71e4dc69fbb12fa5798eaf5315fbe44220149e3..18b672d146b0283df6986a5ae478569da1f7e06f 100644 (file)
@@ -106,7 +106,7 @@ LWGEOM_GEOS_buildArea(const GEOSGeometry* geom_in)
        GEOSGeometry *tmp;
        GEOSGeometry *geos_result, *shp;
        GEOSGeometry const *vgeoms[1];
-       unsigned int i, ngeoms;
+       uint32 i, ngeoms;
 
        vgeoms[0] = geom_in;
        geos_result = GEOSPolygonize(vgeoms, 1);
@@ -596,7 +596,7 @@ Datum pgis_union_geometry_array(PG_FUNCTION_ARGS)
                                                PG_RETURN_NULL();
                                        }
                                        SRID = pglwgeom_getSRID(geom);
-                                       POSTGIS_DEBUGF(3, "first geom is a %s", lwgeom_typename(TYPE_GETTYPE(geom->type)));
+                                       POSTGIS_DEBUGF(3, "first geom is a %s", lwtype_name(TYPE_GETTYPE(geom->type)));
                                }
                                else
                                {
@@ -612,7 +612,7 @@ Datum pgis_union_geometry_array(PG_FUNCTION_ARGS)
                                        }
 
                                        POSTGIS_DEBUGF(3, "unite_garray(%d): adding geom %d to union (%s)",
-                                                      call, i, lwgeom_typename(TYPE_GETTYPE(geom->type)));
+                                                      call, i, lwtype_name(TYPE_GETTYPE(geom->type)));
 
                                        g2 = GEOSUnion(g1, geos_result);
                                        if ( g2 == NULL )
@@ -3274,8 +3274,8 @@ Datum isring(PG_FUNCTION_ARGS)
 POINTARRAY *
 ptarray_from_GEOSCoordSeq(const GEOSCoordSequence *cs, char want3d)
 {
-       unsigned int dims=2;
-       unsigned int size, i, ptsize;
+       uint32 dims=2;
+       uint32 size, i, ptsize;
        uchar *points, *ptr;
        POINTARRAY *ret;
 
@@ -3351,7 +3351,7 @@ GEOS2LWGEOM(const GEOSGeometry *geom, char want3d)
                POINTARRAY *pa, **ppaa;
                const GEOSGeometry *g;
                LWGEOM **geoms;
-               unsigned int i, ngeoms;
+               uint32 i, ngeoms;
 
        case GEOS_POINT:
                POSTGIS_DEBUG(4, "lwgeom_from_geometry: it's a Point");
@@ -3448,8 +3448,8 @@ GEOSGeom LWGEOM2GEOS(LWGEOM *lwgeom);
 GEOSCoordSeq
 ptarray_to_GEOSCoordSeq(POINTARRAY *pa)
 {
-       unsigned int dims = 2;
-       unsigned int size, i;
+       uint32 dims = 2;
+       uint32 size, i;
        POINT3DZ p;
        GEOSCoordSeq sq;
 
@@ -3480,14 +3480,14 @@ LWGEOM2GEOS(LWGEOM *lwgeom)
        /*
        LWGEOM *tmp;
        */
-       unsigned int ngeoms, i;
+       uint32 ngeoms, i;
        int type = 0;
        int geostype;
 #if POSTGIS_DEBUG_LEVEL >= 4
        char *wkt;
 #endif
 
-       POSTGIS_DEBUGF(4, "LWGEOM2GEOS got a %s", lwgeom_typename(type));
+       POSTGIS_DEBUGF(4, "LWGEOM2GEOS got a %s", lwtype_name(type));
 
        if (has_arc(lwgeom))
        {
@@ -3669,7 +3669,7 @@ Datum polygonize_garray(PG_FUNCTION_ARGS)
        Datum datum;
        ArrayType *array;
        int is3d = 0;
-       unsigned int nelems, i;
+       uint32 nelems, i;
        PG_LWGEOM *result;
        GEOSGeometry *geos_result;
        const GEOSGeometry **vgeoms;
index 8402e345579852687eeb4654dc2abed0ae5cd348..3953f932bed4bcad4ca5247ea1dc7f93a7d13ca6 100644 (file)
  * Return Nth vertex in GEOSGeometry as a POINT.
  * May return NULL if the geometry has NO vertexex.
  */
-GEOSGeometry* LWGEOM_GEOS_getPointN(const GEOSGeometry*, unsigned int);
+GEOSGeometry* LWGEOM_GEOS_getPointN(const GEOSGeometry*, uint32);
 GEOSGeometry*
-LWGEOM_GEOS_getPointN(const GEOSGeometry* g_in, unsigned int n)
+LWGEOM_GEOS_getPointN(const GEOSGeometry* g_in, uint32 n)
 {
-       unsigned int dims;
+       uint32 dims;
        const GEOSCoordSequence* seq_in;
        GEOSCoordSeq seq_out;
        double val;
-       unsigned int sz;
+       uint32 sz;
        int gn;
        GEOSGeometry* ret;
 
@@ -570,10 +570,10 @@ LWGEOM_GEOS_makeValidMultiLine(const GEOSGeometry* gin)
        GEOSGeometry* mline_out=0;
        GEOSGeometry* mpoint_out=0;
        GEOSGeometry* gout;
-       unsigned int nlines;
-       unsigned int npoints=0;
-       unsigned int ngeoms=0;
-       unsigned int i;
+       uint32 nlines;
+       uint32 npoints=0;
+       uint32 ngeoms=0;
+       uint32 i;
 
        ngeoms = GEOSGetNumGeometries(gin);
 
@@ -879,8 +879,8 @@ lwgeom_clean(LWGEOM* lwgeom_in)
        {
                lwnotice("lwgeom_clean: mixed-type output (%s) "
                        "from single-type input (%s)",
-                       lwgeom_typename(TYPE_GETTYPE(lwgeom_out->type)),
-                       lwgeom_typename(TYPE_GETTYPE(lwgeom_in->type)));
+                       lwtype_name(TYPE_GETTYPE(lwgeom_out->type)),
+                       lwtype_name(TYPE_GETTYPE(lwgeom_in->type)));
                return NULL;
        }
 
index 16b90b1af1811a9cb43307003acc8537b7e026aa..09ff158b34b39b6b557836ca755318aaeadfceca 100644 (file)
@@ -209,7 +209,7 @@ lwline_split(LWLINE* lwline_in, LWGEOM* blade_in)
 
        default:
                lwerror("Splitting a Line by a %s is unsupported",
-                       lwgeom_typename(TYPE_GETTYPE(blade_in->type)));
+                       lwtype_name(TYPE_GETTYPE(blade_in->type)));
                return NULL;
        }
        return NULL;
@@ -378,7 +378,7 @@ lwpoly_split(LWPOLY* lwpoly_in, LWGEOM* blade_in)
                return lwpoly_split_by_line(lwpoly_in, (LWLINE*)blade_in);
        default:
                lwerror("Splitting a Polygon by a %s is unsupported",
-                       lwgeom_typename(TYPE_GETTYPE(blade_in->type)));
+                       lwtype_name(TYPE_GETTYPE(blade_in->type)));
                return NULL;
        }
        return NULL;
@@ -398,7 +398,7 @@ lwgeom_split(LWGEOM* lwgeom_in, LWGEOM* blade_in)
 
        default:
                lwerror("Splitting of %s geometries is unsupported",
-                       lwgeom_typename(TYPE_GETTYPE(lwgeom_in->type)));
+                       lwtype_name(TYPE_GETTYPE(lwgeom_in->type)));
                return NULL;
        }
 
index f2fc4f71d280fe784a2a44239ccc92d81c6df120..e3156f9cfcb01594280261f9b42aab6b936d2c00 100644 (file)
@@ -778,7 +778,7 @@ PG_FUNCTION_INFO_V1(LWGEOM_gist_decompress);
 Datum LWGEOM_gist_decompress(PG_FUNCTION_ARGS)
 {
 #if POSTGIS_DEBUG_LEVEL >= 4
-       static unsigned int counter2 = 0;
+       static uint32 counter2 = 0;
        counter2++;
        POSTGIS_DEBUGF(4, "GIST: LWGEOM_gist_decompress called %i",counter2);
 #endif
index dbd429e4adf072e270e3027b8cf0a3ba230b3911..86b19f68a6ea1c1a590eaafa72818e8518109d95 100644 (file)
@@ -1054,7 +1054,7 @@ static LWGEOM* parse_gml_curve(xmlNodePtr xnode, bool *hasz, int *root_srid)
        LWGEOM *geom=NULL;
        POINTARRAY *pa=NULL;
        POINTARRAY **ppa=NULL;
-       unsigned int npoints=0;
+       uint32 npoints=0;
        xmlChar *interpolation=NULL;
 
        if (is_xlink(xnode)) xnode = get_xlink_node(xnode);
@@ -1402,12 +1402,12 @@ static LWGEOM* parse_gml_mpoint(xmlNodePtr xnode, bool *hasz, int *root_srid)
        {
                *root_srid = srs->srid;
                geom = (LWGEOM *)lwcollection_construct_empty(*root_srid, 1, 0);
-               geom->type = lwgeom_makeType(1, 1, 0, MULTIPOINTTYPE);
+               TYPE_SETTYPE(geom->type, MULTIPOINTTYPE);
        }
        else
        {
                geom = (LWGEOM *)lwcollection_construct_empty(-1, 1, 0);
-               geom->type = lwgeom_makeType(1, 0, 0, MULTIPOINTTYPE);
+               TYPE_SETTYPE(geom->type, MULTIPOINTTYPE);
        }
        lwfree(srs);
 
@@ -1419,8 +1419,7 @@ static LWGEOM* parse_gml_mpoint(xmlNodePtr xnode, bool *hasz, int *root_srid)
                if (!is_gml_namespace(xa, false)) continue;
                if (strcmp((char *) xa->name, "pointMember")) continue;
                if (xa->children != NULL)
-                       geom = lwmpoint_add((LWMPOINT *)geom, -1,
-                                           parse_gml(xa->children, hasz, root_srid));
+                       geom = (LWGEOM*)lwmpoint_add_lwpoint((LWMPOINT*)geom, (LWPOINT*)parse_gml(xa->children, hasz, root_srid));
        }
 
        return geom;
@@ -1443,12 +1442,12 @@ static LWGEOM* parse_gml_mline(xmlNodePtr xnode, bool *hasz, int *root_srid)
        {
                *root_srid = srs->srid;
                geom = (LWGEOM *)lwcollection_construct_empty(*root_srid, 1, 0);
-               geom->type = lwgeom_makeType(1, 1, 0, MULTILINETYPE);
+               TYPE_SETTYPE(geom->type, MULTILINETYPE);
        }
        else
        {
                geom = (LWGEOM *)lwcollection_construct_empty(-1, 1, 0);
-               geom->type = lwgeom_makeType(1, 0, 0, MULTILINETYPE);
+               TYPE_SETTYPE(geom->type, MULTILINETYPE);
        }
        lwfree(srs);
 
@@ -1460,8 +1459,7 @@ static LWGEOM* parse_gml_mline(xmlNodePtr xnode, bool *hasz, int *root_srid)
                if (!is_gml_namespace(xa, false)) continue;
                if (strcmp((char *) xa->name, "lineStringMember")) continue;
                if (xa->children != NULL)
-                       geom = lwmline_add((LWMLINE *)geom, -1,
-                                          parse_gml(xa->children, hasz, root_srid));
+                       geom = (LWGEOM*)lwmline_add_lwline((LWMLINE*)geom, (LWLINE*)parse_gml(xa->children, hasz, root_srid));
        }
 
        return geom;
@@ -1484,12 +1482,12 @@ static LWGEOM* parse_gml_mcurve(xmlNodePtr xnode, bool *hasz, int *root_srid)
        {
                *root_srid = srs->srid;
                geom = (LWGEOM *)lwcollection_construct_empty(*root_srid, 1, 0);
-               geom->type = lwgeom_makeType(1, 1, 0, MULTILINETYPE);
+               TYPE_SETTYPE(geom->type, MULTILINETYPE);
        }
        else
        {
                geom = (LWGEOM *)lwcollection_construct_empty(-1, 1, 0);
-               geom->type = lwgeom_makeType(1, 0, 0, MULTILINETYPE);
+               TYPE_SETTYPE(geom->type, MULTILINETYPE);
        }
        lwfree(srs);
 
@@ -1501,8 +1499,7 @@ static LWGEOM* parse_gml_mcurve(xmlNodePtr xnode, bool *hasz, int *root_srid)
                if (!is_gml_namespace(xa, false)) continue;
                if (strcmp((char *) xa->name, "curveMember")) continue;
                if (xa->children != NULL)
-                       geom = lwmline_add((LWMLINE *)geom, -1,
-                                          parse_gml(xa->children, hasz, root_srid));
+                       geom = (LWGEOM*)lwmline_add_lwline((LWMLINE*)geom, (LWLINE*)parse_gml(xa->children, hasz, root_srid));
        }
 
        return geom;
@@ -1525,12 +1522,12 @@ static LWGEOM* parse_gml_mpoly(xmlNodePtr xnode, bool *hasz, int *root_srid)
        {
                *root_srid = srs->srid;
                geom = (LWGEOM *)lwcollection_construct_empty(*root_srid, 1, 0);
-               geom->type = lwgeom_makeType(1, 1, 0, MULTIPOLYGONTYPE);
+               TYPE_SETTYPE(geom->type, MULTIPOLYGONTYPE);
        }
        else
        {
                geom = (LWGEOM *)lwcollection_construct_empty(-1, 1, 0);
-               geom->type = lwgeom_makeType(1, 0, 0, MULTIPOLYGONTYPE);
+               TYPE_SETTYPE(geom->type, MULTIPOLYGONTYPE);
        }
        lwfree(srs);
 
@@ -1542,8 +1539,7 @@ static LWGEOM* parse_gml_mpoly(xmlNodePtr xnode, bool *hasz, int *root_srid)
                if (!is_gml_namespace(xa, false)) continue;
                if (strcmp((char *) xa->name, "polygonMember")) continue;
                if (xa->children != NULL)
-                       geom = lwmpoly_add((LWMPOLY *)geom, -1,
-                                          parse_gml(xa->children, hasz, root_srid));
+                       geom = (LWGEOM*)lwmpoly_add_lwpoly((LWMPOLY*)geom, (LWPOLY*)parse_gml(xa->children, hasz, root_srid));
        }
 
        return geom;
@@ -1566,12 +1562,12 @@ static LWGEOM* parse_gml_msurface(xmlNodePtr xnode, bool *hasz, int *root_srid)
        {
                *root_srid = srs->srid;
                geom = (LWGEOM *)lwcollection_construct_empty(*root_srid, 1, 0);
-               geom->type = lwgeom_makeType(1, 1, 0, MULTIPOLYGONTYPE);
+               TYPE_SETTYPE(geom->type, MULTIPOLYGONTYPE);
        }
        else
        {
                geom = (LWGEOM *)lwcollection_construct_empty(-1, 1, 0);
-               geom->type = lwgeom_makeType(1, 0, 0, MULTIPOLYGONTYPE);
+               TYPE_SETTYPE(geom->type, MULTIPOLYGONTYPE);
        }
        lwfree(srs);
 
@@ -1583,8 +1579,7 @@ static LWGEOM* parse_gml_msurface(xmlNodePtr xnode, bool *hasz, int *root_srid)
                if (!is_gml_namespace(xa, false)) continue;
                if (strcmp((char *) xa->name, "surfaceMember")) continue;
                if (xa->children != NULL)
-                       geom = lwmpoly_add((LWMPOLY *)geom, -1,
-                                          parse_gml(xa->children, hasz, root_srid));
+                       geom = (LWGEOM*)lwmpoly_add_lwpoly((LWMPOLY*)geom, (LWPOLY*)parse_gml(xa->children, hasz, root_srid));
        }
 
        return geom;
@@ -1607,12 +1602,12 @@ static LWGEOM* parse_gml_coll(xmlNodePtr xnode, bool *hasz, int *root_srid)
        {
                *root_srid = srs->srid;
                geom = (LWGEOM *)lwcollection_construct_empty(*root_srid, 1, 0);
-               geom->type = lwgeom_makeType(1, 1, 0, COLLECTIONTYPE);
+               TYPE_SETTYPE(geom->type, COLLECTIONTYPE);
        }
        else
        {
                geom = (LWGEOM *)lwcollection_construct_empty(-1, 1, 0);
-               geom->type = lwgeom_makeType(1, 0, 0, COLLECTIONTYPE);
+               TYPE_SETTYPE(geom->type, COLLECTIONTYPE);
        }
        lwfree(srs);
 
@@ -1634,8 +1629,7 @@ static LWGEOM* parse_gml_coll(xmlNodePtr xnode, bool *hasz, int *root_srid)
                {
 
                        if (xa->children == NULL) break;
-                       geom = lwcollection_add((LWCOLLECTION *)geom, -1,
-                                               parse_gml(xa->children, hasz, root_srid));
+                       geom = (LWGEOM*)lwcollection_add_lwgeom((LWCOLLECTION *)geom, parse_gml(xa->children, hasz, root_srid));
                }
        }
 
index da386c6362bd24c3322cc03ad8caaaacdc4a7dd3..5f796c667950d947dd753565e63224521c30a7f6 100644 (file)
@@ -469,8 +469,7 @@ static LWGEOM* parse_kml_multi(xmlNodePtr xnode, bool *hasz)
                {
 
                        if (xa->children == NULL) break;
-                       geom = lwcollection_add((LWCOLLECTION *)geom, -1,
-                                               parse_kml(xa, hasz));
+                       geom = (LWGEOM*)lwcollection_add_lwgeom((LWCOLLECTION*)geom, parse_kml(xa, hasz));
                }
        }
 
index bef05b0eb5f2a9bee82a4498ee297298a287947d..19bbad2bf674de4ee8abb4e617ee66ca063d96fb 100644 (file)
@@ -131,7 +131,7 @@ Datum LWGEOM_to_latlon(PG_FUNCTION_ARGS)
        uchar geom_type = TYPE_GETTYPE(pg_lwgeom->type);
        if (POINTTYPE != geom_type)
        {
-               lwerror("Only points are supported, you tried type %s.", lwgeom_typename(geom_type));
+               lwerror("Only points are supported, you tried type %s.", lwtype_name(geom_type));
        }
        /* Convert to LWGEOM type */
        lwgeom = lwgeom_deserialize(SERIALIZED_FORM(pg_lwgeom));
@@ -144,14 +144,14 @@ Datum LWGEOM_to_latlon(PG_FUNCTION_ARGS)
                format_str[str_size] = 0; /* null term */
 
                /* The input string supposedly will be in the database encoding, so convert to UTF-8. */
-               format_str_utf8 = (char *)pg_do_encoding_conversion((unsigned char *)format_str, str_size, GetDatabaseEncoding(), PG_UTF8);
+               format_str_utf8 = (char *)pg_do_encoding_conversion((uchar *)format_str, str_size, GetDatabaseEncoding(), PG_UTF8);
        }
 
        /* Produce the formatted string. */
        formatted_str_utf8 = lwpoint_to_latlon((LWPOINT *)lwgeom, format_str_utf8);
 
        /* Convert the formatted string from UTF-8 back to database encoding. */
-       formatted_str = (char *)pg_do_encoding_conversion((unsigned char *)formatted_str_utf8, strlen(formatted_str_utf8), PG_UTF8, GetDatabaseEncoding());
+       formatted_str = (char *)pg_do_encoding_conversion((uchar *)formatted_str_utf8, strlen(formatted_str_utf8), PG_UTF8, GetDatabaseEncoding());
 
        /* Convert to the postgres output string type. */
        str_size = strlen(formatted_str) + VARHDRSZ;
@@ -204,7 +204,7 @@ Datum LWGEOM_asHEXEWKB(PG_FUNCTION_ARGS)
        int result;
        text *text_result;
        text *type;
-       unsigned int byteorder=-1;
+       uint32 byteorder=-1;
 
        lwgeom = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 
@@ -331,7 +331,7 @@ Datum WKBFromLWGEOM(PG_FUNCTION_ARGS)
        int t;
 #endif /* BINARY_FROM_HEX */
        text *type;
-       unsigned int byteorder=-1;
+       uint32 byteorder=-1;
 
        PROFSTART(PROF_QRUN);
 
index 20d029763b3e06ced2bdf8c99f23c5a97a9aba44..d4f7b9b4b529e5f2ce5c5e513f6809765209f1e7 100644 (file)
@@ -182,7 +182,7 @@ Datum geometry_geometrytype(PG_FUNCTION_ARGS)
 
        /* Build up the output string */
        strncat(type_str, "ST_", 32);
-       strncat(type_str, lwgeom_typename(lwgeom_getType(lwgeom->type)), 32);
+       strncat(type_str, lwtype_name(lwgeom_getType(lwgeom->type)), 32);
        size = strlen(type_str) + VARHDRSZ;
 
        /* Build a text type to store things in */