+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
{
int type = TYPE_GETTYPE(geom->type);
- LWDEBUGF(2, "Input type: %s", lwgeom_typename(type));
+ LWDEBUGF(2, "Input type: %s", lwtype_name(type));
switch (type)
{
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)
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);
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);
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);
}
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;
}
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)
{
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)
uchar gflags(int hasz, int hasm, int geodetic)
{
- unsigned char flags = 0;
+ uchar flags = 0;
if ( hasz )
FLAGS_SET_Z(flags, 1);
if ( hasm )
#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.
#define MAXFLOAT 3.402823466e+38F
#endif
-#ifndef C_H
+typedef unsigned char uchar;
+#ifndef C_H
typedef unsigned int uint32;
typedef int int32;
-
#endif
/**
/******************************************************************/
-typedef unsigned char uchar;
typedef struct
{
/* use TYPE_* macros to handle */
uchar dims;
- uint32 npoints;
+ int npoints;
+ int maxpoints;
}
POINTARRAY;
uchar type; /* LINETYPE */
BOX2DFLOAT4 *bbox;
uint32 SRID;
- POINTARRAY *points; /* array of POINT3D */
+ POINTARRAY *points; /* array of POINT3D */
}
LWLINE; /* "light-weight line" */
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" */
uchar type;
BOX2DFLOAT4 *bbox;
uint32 SRID;
- int ngeoms;
+ int ngeoms;
+ int maxgeoms;
LWPOINT **geoms;
}
LWMPOINT;
uchar type;
BOX2DFLOAT4 *bbox;
uint32 SRID;
- int ngeoms;
+ int ngeoms;
+ int maxgeoms;
LWLINE **geoms;
}
LWMLINE;
uchar type;
BOX2DFLOAT4 *bbox;
uint32 SRID;
- int ngeoms;
+ int ngeoms;
+ int maxgeoms;
LWPOLY **geoms;
}
LWMPOLY;
uchar type;
BOX2DFLOAT4 *bbox;
uint32 SRID;
- int ngeoms;
+ int ngeoms;
+ int maxgeoms;
LWGEOM **geoms;
}
LWCOLLECTION;
BOX2DFLOAT4 *bbox;
uint32 SRID;
int ngeoms;
+ int maxgeoms;
LWGEOM **geoms;
}
LWCOMPOUND; /* "light-weight compound line" */
BOX2DFLOAT4 *bbox;
uint32 SRID;
int nrings;
+ int maxrings;
LWGEOM **rings; /* list of rings (list of points) */
}
LWCURVEPOLY; /* "light-weight polygon" */
BOX2DFLOAT4 *bbox;
uint32 SRID;
int ngeoms;
+ int maxgeoms;
LWGEOM **geoms;
}
LWMCURVE;
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
#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)))
* 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
/*
* 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);
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))
#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);
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);
/* 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);
/**
* 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
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
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);
*/
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);
* 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);
#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);
/*
** New parsing and unparsing functions.
*/
-extern char *lwgeom_to_wkt(const LWGEOM *geom, uchar variant, int precision, size_t *size_out);
+extern char* lwgeom_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);
/* 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);
* 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);
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);
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;
}
* 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;
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.");
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)
{
* 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;
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;
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;
}
LWCIRCSTRING *
-lwcircstring_addpoint(LWCIRCSTRING *curve, LWPOINT *point, unsigned int where)
+lwcircstring_addpoint(LWCIRCSTRING *curve, LWPOINT *point, uint32 where)
{
POINTARRAY *newpa;
LWCIRCSTRING *ret;
}
LWCIRCSTRING *
-lwcircstring_removepoint(LWCIRCSTRING *curve, unsigned int index)
+lwcircstring_removepoint(LWCIRCSTRING *curve, uint32 index)
{
POINTARRAY *newpa;
LWCIRCSTRING *ret;
* 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);
}
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);
type, 0);
ret->SRID = SRID;
ret->ngeoms = ngeoms;
+ ret->maxgeoms = ngeoms;
ret->geoms = geoms;
ret->bbox = 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;
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);
}
int
-lwcollection_compute_box2d_p(LWCOLLECTION *col, BOX2DFLOAT4 *box)
+lwcollection_compute_box2d_p(const LWCOLLECTION *col, BOX2DFLOAT4 *box)
{
BOX2DFLOAT4 boxbuf;
uint32 i;
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);
char
lwcollection_same(const LWCOLLECTION *c1, const LWCOLLECTION *c2)
{
- unsigned int i;
+ uint32 i;
LWDEBUG(2, "lwcollection_same called");
/* 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++)
{
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;
}
LWGEOM*
lwcollection_remove_repeated_points(LWCOLLECTION *coll)
{
- unsigned int i;
+ uint32 i;
LWGEOM **newgeoms;
newgeoms = lwalloc(sizeof(LWGEOM *)*coll->ngeoms);
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;
-}
&& 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;
return result;
}
-LWGEOM *
-lwcurvepoly_add(const LWCURVEPOLY *to, uint32 where, const LWGEOM *what)
-{
- /* TODO */
- lwerror("lwcurvepoly_add not yet implemented.");
- return NULL;
-}
-
}
- 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;
}
{
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)
{
return (LWGEOM *)lwmsurface_deserialize(srl);
default:
lwerror("lwgeom_deserialize: Unknown geometry type: %s",
- lwgeom_typename(type));
+ lwtype_name(type));
return NULL;
}
{
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)
{
return lwcollection_serialize_size((LWCOLLECTION *)lwgeom);
default:
lwerror("lwgeom_serialize_size: Unknown geometry type: %s",
- lwgeom_typename(type));
+ lwtype_name(type));
return 0;
}
int type = TYPE_GETTYPE(lwgeom->type);
LWDEBUGF(2, "lwgeom_serialize_buf called with a %s",
- lwgeom_typename(type));
+ lwtype_name(type));
switch (type)
{
break;
default:
lwerror("lwgeom_serialize_buf: Unknown geometry type: %s",
- lwgeom_typename(type));
+ lwtype_name(type));
return;
}
return;
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))
{
/**
* 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;
}
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;
}
/**
** Look-up for the correct MULTI* type promotion for singleton types.
*/
-static unsigned char MULTITYPE[16] =
+static uchar MULTITYPE[16] =
{
0,
MULTIPOINTTYPE,
* 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;
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);
}
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))
{
}
}
-/**
- * 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;
/**
* 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);
* - construct PG_LWGEOM
* - deserialize it
*/
-LWGEOM *
+LWGEOM*
lwgeom_from_ewkb(uchar *ewkb, int flags, size_t size)
{
size_t hexewkblen = size*2;
/**
* Make an LWGEOM object from a EWKT representation.
*/
-LWGEOM *
+LWGEOM*
lwgeom_from_ewkt(char *ewkt, int flags)
{
int result;
* 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;
* 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;
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) )
{
(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;
}
return;
default:
lwerror("lwgeom_longitude_shift: unsupported geom type: %s",
- lwgeom_typename(TYPE_GETTYPE(lwgeom->type)));
+ lwtype_name(TYPE_GETTYPE(lwgeom->type)));
}
}
case COMPOUNDTYPE:
case MULTICURVETYPE:
case MULTISURFACETYPE:
- return -1;
+ return LW_TRUE;
break;
default:
- return 0;
+ return LW_FALSE;
}
}
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))
{
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);
{
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))
{
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;
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))
{
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;
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))
{
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;
}
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))
{
default:
lwerror("lwgeom_flip_coordinates: unsupported geometry type: %s",
- lwgeom_typename(TYPE_GETTYPE(in->type)));
+ lwtype_name(TYPE_GETTYPE(in->type)));
}
return NULL;
}
* 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) \
* 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);
}
-float nextDown_f(double d)
+float next_float_down(double d)
{
float result = d;
* handles the funny differences in float4 and float8 reps.
*/
float
-nextUp_f(double d)
+next_float_up(double d)
{
float result = d;
* handles the funny differences in float4 and float8 reps.
*/
double
-nextDown_d(float d)
+next_double_down(float d)
{
double result = d;
* handles the funny differences in float4 and float8 reps.
*/
double
-nextUp_d(float d)
+next_double_up(float d)
{
double result = d;
}
#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;
}
}
#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;
}
* Basic sub-geometry types
*****************************************************************************/
-/* handle missaligned unsigned int32 data */
+/* handle missaligned uint3232 data */
uint32
lw_get_uint32(const uchar *loc)
{
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));
}
/**
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);
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
/* 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);
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.");
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.");
output_wkt(uchar* geom, int supress)
{
- unsigned char type=*geom++;
+ uchar type=*geom++;
char writeM=0;
dims = TYPE_NDIMS(type); /* ((type & 0x30) >> 4)+2; */
/* 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);
/* 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);
/* 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);
/* 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);
uchar *
output_wkb(uchar* geom)
{
- unsigned char type=*geom++;
+ uchar type=*geom++;
int4 wkbtype;
dims = TYPE_NDIMS(type);
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);
if (((LWCOLLECTION *) geom)->ngeoms == 1)
{
- hgeom =lwgeom_clone((LWGEOM *)
+ hgeom = lwgeom_clone((LWGEOM *)
((LWCOLLECTION *)geom)->geoms[0]);
hgeom->SRID = geom->SRID;
return lwcollection_homogenize((LWCOLLECTION *) geom);
lwerror("lwgeom_homogenize: Geometry Type not supported (%i)",
- lwgeom_typename(type));
+ lwtype_name(type));
return NULL; /*Never reach */
}
LWGEOM *
lwcollection_homogenize(const LWCOLLECTION *col)
{
- unsigned int i;
+ uint32 i, srid;
uchar hasz, hasm;
LWGEOM *res = NULL;
LWCOLLECTION *coll;
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++)
/* 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;
}
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;
}
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.
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;
}
}
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);
}
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)
* 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;
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;
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;
}
LWLINE *
-lwline_addpoint(LWLINE *line, LWPOINT *point, unsigned int where)
+lwline_addpoint(LWLINE *line, LWPOINT *point, uint32 where)
{
POINTARRAY *newpa;
LWLINE *ret;
}
LWLINE *
-lwline_removepoint(LWLINE *line, unsigned int index)
+lwline_removepoint(LWLINE *line, uint32 index)
{
POINTARRAY *newpa;
LWLINE *ret;
* 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 */
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;
-}
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)
{
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);
}
/**
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)
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)
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);
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)
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;
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;
-}
bbox = NULL;
}
lwerror("lwgeom_to_geojson: '%s' geometry type not supported",
- lwgeom_typename(type));
+ lwtype_name(type));
}
if (bbox)
default:
lwerror("lwgeom_to_gml2: '%s' geometry type not supported",
- lwgeom_typename(type));
+ lwtype_name(type));
return NULL;
}
}
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;
}
}
default:
lwerror("lwgeom_to_kml2: '%s' geometry type not supported",
- lwgeom_typename(type));
+ lwtype_name(type));
return NULL;
}
}
default:
lwerror("lwgeom_to_svg: '%s' geometry type not supported",
- lwgeom_typename(type));
+ lwtype_name(type));
}
return ret;
default:
lwerror("ST_AsSVG: '%s' geometry type not supported.",
- lwgeom_typename(type));
+ lwtype_name(type));
}
return (ptr-output);
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
*/
/*
* 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;
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 )
/*
* 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)) ||
/*
* 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;
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++ )
{
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 */
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;
}
/* 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
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 */
/* 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;
/* 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++ )
{
/* 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++ )
{
/* 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;
/* 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;
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;
}
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);
}
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
/* 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");
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)
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;
}
}
int
-lwpoly_compute_box2d_p(LWPOLY *poly, BOX2DFLOAT4 *box)
+lwpoly_compute_box2d_p(const LWPOLY *poly, BOX2DFLOAT4 *box)
{
BOX2DFLOAT4 boxbuf;
uint32 i;
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)
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++)
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++)
*/
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;
LWGEOM*
lwpoly_remove_repeated_points(LWPOLY *poly)
{
- unsigned int i;
+ uint32 i;
POINTARRAY **newrings;
newrings = lwalloc(sizeof(POINTARRAY *)*poly->nrings);
* 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)
* 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;
POINTARRAY *result;
POINT4D pbuf;
size_t ptsize = sizeof(POINT4D);
- unsigned int ptcount;
+ uint32 ptcount;
uchar *pt;
POINT4D *center;
}
-const char* lwgeom_typename(int type)
+const char* lwtype_name(int type)
{
/* something went wrong somewhere */
if ( type < 0 || type > 15 )
}
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(t2));
+ lwerror("Unsupported geometry type: %s", lwtype_name(t2));
return LW_FALSE;
}
}
}
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*/
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)
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;
*
*/
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;
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;
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;
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;
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;
* (depending on its dimensions)
*/
double
-lwgeom_pointarray_length(POINTARRAY *pts)
+lwgeom_pointarray_length(const POINTARRAY *pts)
{
double dist = 0.0;
int i;
* 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;
* 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;
* 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;
* 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 )
{
#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;
}
+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)
{
/**
* 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;
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;
* 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;
* @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);
}
LWGEOM_UNPARSER_RESULT;
#endif
+
typedef void* (*allocator)(size_t size);
typedef void (*freeor)(void* mem);
typedef void (*report_error)(const char* string, ...);
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;
char *pgtype;
/* PostGIS geometry type (numeric version) */
- unsigned int wkbtype;
+ uint32 wkbtype;
/* Number of dimensions to output */
int pgdims;
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));
}
}
{
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) )));
}
}
{
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. */
/* 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) )
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) )
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);
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:
char *lwpoint_summary(LWPOINT *point, int offset);
char *
-lwgeom_summary(LWGEOM *lwgeom, int offset)
+lwgeom_summary(const LWGEOM *lwgeom, int offset)
{
char *result;
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;
}
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;
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);
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);
Datum result;
char address[256];
char *ptr;
- unsigned int i;
+ uint32 i;
char *values[2];
if (SRF_IS_FIRSTCALL())
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;
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 *));
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;
}
}
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();
}
#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);
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();
}
#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);
* 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 */
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");
* 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 */
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");
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;
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) )
/*PG_LWGEOM **geoms; */
PG_LWGEOM *result=NULL;
LWGEOM **lwgeoms, *outlwg;
- unsigned int outtype;
+ uint32 outtype;
int i, count;
int SRID=-1;
size_t offset;
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));
PG_LWGEOM *result=NULL;
LWPOINT **lwpoints;
LWGEOM *outlwg;
- unsigned int npoints;
+ uint32 npoints;
int i;
size_t offset;
int SRID=-1;
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.");
{
PG_LWGEOM *pglwg1, *result;
LWLINE *line, *outline;
- unsigned int which;
+ uint32 which;
POSTGIS_DEBUG(2, "LWGEOM_removepoint called.");
LWLINE *line;
LWPOINT *lwpoint;
POINT4D newpoint;
- unsigned int which;
+ uint32 which;
POSTGIS_DEBUG(2, "LWGEOM_setpoint_linestring called.");
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);
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
{
}
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 )
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;
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");
GEOSCoordSeq
ptarray_to_GEOSCoordSeq(POINTARRAY *pa)
{
- unsigned int dims = 2;
- unsigned int size, i;
+ uint32 dims = 2;
+ uint32 size, i;
POINT3DZ p;
GEOSCoordSeq sq;
/*
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))
{
Datum datum;
ArrayType *array;
int is3d = 0;
- unsigned int nelems, i;
+ uint32 nelems, i;
PG_LWGEOM *result;
GEOSGeometry *geos_result;
const GEOSGeometry **vgeoms;
* 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;
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);
{
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;
}
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;
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;
default:
lwerror("Splitting of %s geometries is unsupported",
- lwgeom_typename(TYPE_GETTYPE(lwgeom_in->type)));
+ lwtype_name(TYPE_GETTYPE(lwgeom_in->type)));
return NULL;
}
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
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);
{
*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);
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;
{
*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);
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;
{
*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);
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;
{
*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);
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;
{
*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);
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;
{
*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);
{
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));
}
}
{
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));
}
}
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));
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;
int result;
text *text_result;
text *type;
- unsigned int byteorder=-1;
+ uint32 byteorder=-1;
lwgeom = (PG_LWGEOM *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
int t;
#endif /* BINARY_FROM_HEX */
text *type;
- unsigned int byteorder=-1;
+ uint32 byteorder=-1;
PROFSTART(PROF_QRUN);
/* 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 */