diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index d96a26a..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,17 +0,0 @@
-# Mac
-
-.DS_Store
-
-# Xcode
-
-xcuserdata
-
-# Carthage
-
-Carthage/Checkouts
-Carthage/Build
-
-# Swift Package Manager
-
-.build/
-.swiftpm/
diff --git a/LICENSE b/LICENSE
index 8cdb845..e51146a 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,340 +1,21 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Lesser General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- {description}
- Copyright (C) {year} {fullname}
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- {signature of Ty Coon}, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.
-
+MIT License
+
+Copyright (c) 2025 Scott Hoyt, Andrew Hershberger
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/Package.swift b/Package.swift
deleted file mode 100644
index 32574dd..0000000
--- a/Package.swift
+++ /dev/null
@@ -1,24 +0,0 @@
-// swift-tools-version:5.9
-import PackageDescription
-
-let package = Package(
- name: "geos",
- platforms: [.iOS(.v12), .macOS(.v10_13), .tvOS(.v12), .watchOS(.v4), .visionOS(.v1)],
- products: [
- .library(
- name: "geos",
- type: .dynamic,
- targets: ["geos"]),
- ],
- targets: [
- .target(
- name: "geos",
- publicHeadersPath: "public",
- cxxSettings: [
- .define("USE_UNSTABLE_GEOS_CPP_API"),
- .define("NDEBUG"),
- .headerSearchPath("include"),
- .headerSearchPath("src/deps")])
- ],
- cxxLanguageStandard: .cxx17
-)
diff --git a/README.md b/README.md
deleted file mode 100644
index bcfcde8..0000000
--- a/README.md
+++ /dev/null
@@ -1,88 +0,0 @@
-# GEOS
-
-[](https://swift.org/package-manager/)
-[](https://cocoapods.org)
-[](https://github.com/GEOSwift/geos)
-[](https://github.com/GEOSwift/geos/actions/workflows/main.yml)
-
-GEOS is an open source C++ library for working with geospatial geometry. Learn
-more on its [homepage](https://libgeos.org). This repo makes its C interface
-available through Swift Package Manager and CocoaPods so you can use
-it in your Swift or Objective-C project. It is commonly used via
-[GEOSwift](https://github.com/GEOSwift/GEOSwift).
-
-## Minimum Requirements
-
-* iOS 12.0, macOS 10.13, tvOS 12.0, watchOS 4.0, Linux
-* Swift 5.9 compiler
-
-> GEOS is licensed under LGPL 2.1 and its compatibility with static linking is
-at least controversial. Use of geos without dynamic linking is discouraged.
-
-## Upstream Version
-
-GEOSwift/geos 10.0.1 packages [libgeos/geos](https://github.com/libgeos/geos) 3.14.0
-
-## Installing with CocoaPods
-
-1. Update your `Podfile` to include:
-
- use_frameworks!
- pod 'geos'
-
-2. Run `$ pod install`
-
-## Installing with Swift Package Manager
-
-1. Update the top-level dependencies in your `Package.swift` to include:
-
- .package(url: "https://github.com/GEOSwift/geos.git", from: "10.0.1")
-
-2. Update the target dependencies in your `Package.swift` to include
-
- "geos"
-
-## History
-
-Starting with tag 3.7.0 in this repo, the Podspec here should match the one in
-the CocoaPods specs repo. This has not always been the case. For example, the
-3.5.0 tag in this repo does not actually represent what you get if you install
-3.5.0 from CocoaPods. Alas, this situation should be remedied as we move
-forward.
-
-Version 3.7.0 is based on the actually-published 3.5.0 podspec.
-
-Through version 3.7.1, the version numbers in this repo were designed to match
-the corresponding version numbers in GEOS itself. Starting with version 4.0.0,
-we are breaking with this pattern and will instead use semantic versioning on
-this build configuration itself rather than trying to match the underlying geos
-version. This allows us more flexibilty to improve the build config
-independently of the geos release cycle.
-
-## License
-
-The build configurations provided in this repo are licensed under the GPL 2.0.
-See [LICENSE](LICENSE) for full details.
-
-The contents of the Sources directory are taken from the GEOS project which is
-licensed under the LGPL 2.1. See [Sources/COPYING](Sources/COPYING) for full
-details.
-
-## Developing
-
-The most common development activity is updating to a new version of GEOS. To
-get started:
-
-1. Install cmake: `$ brew install cmake`
-2. Modify `update.sh` to indicate the version of GEOS that you wish to use.
-3. Run `update.sh`
-4. Debug any issues. The script may need to be modified to work with newer
-versions of the library. Please keep it up-to-date so that we have a record of
-how to get from the GEOS source to the end result in this repo.
-5. Update `Package.swift` and `geos.podspec` to ensure
-continued support for Swift Package Manager and CocoaPods.
-6. Test all your changes on the full matrix of supported configs
-(Swift Package Manager, CocoaPods) x (iOS, macOS, tvOS, watchOS) + Swift
-Package Manager x Linux.
-7. Update the version numbers in `geos.podspec` and `README.md`
-8. Update this README with any relevant information.
diff --git a/Sources/COPYING b/Sources/COPYING
deleted file mode 100644
index 4362b49..0000000
--- a/Sources/COPYING
+++ /dev/null
@@ -1,502 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- , 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/Sources/geos/capi/geos_c.cpp b/Sources/geos/capi/geos_c.cpp
deleted file mode 100644
index 35d14fd..0000000
--- a/Sources/geos/capi/geos_c.cpp
+++ /dev/null
@@ -1,2077 +0,0 @@
-/************************************************************************
- *
- *
- * C-Wrapper for GEOS library
- *
- * Copyright (C) 2010 2011 Sandro Santilli
- * Copyright (C) 2005-2006 Refractions Research Inc.
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation.
- * See the COPYING file for more information.
- *
- * Author: Sandro Santilli
- *
- ***********************************************************************/
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-#ifdef _MSC_VER
-#pragma warning(disable : 4099)
-#endif
-
-// Some extra magic to make type declarations in geos_c.h work -
-// for cross-checking of types in header.
-// NOTE: the below defines or struct definition must be kept in exact
-// sync between geos_c.cpp and geos_ts_c.cpp to avoid C++ One Definition Rule
-// violations.
-#define GEOSGeometry geos::geom::Geometry
-#define GEOSPreparedGeometry geos::geom::prep::PreparedGeometry
-#define GEOSClusterInfo geos::operation::cluster::Clusters
-#define GEOSCoordSequence geos::geom::CoordinateSequence
-#define GEOSBufferParams geos::operation::buffer::BufferParameters
-#define GEOSSTRtree geos::index::strtree::TemplateSTRtree
-#define GEOSWKTReader geos::io::WKTReader
-#define GEOSWKTWriter geos::io::WKTWriter
-#define GEOSWKBReader geos::io::WKBReader
-#define GEOSWKBWriter geos::io::WKBWriter
-#define GEOSGeoJSONReader geos::io::GeoJSONReader
-#define GEOSGeoJSONWriter geos::io::GeoJSONWriter
-
-// Implementation struct for the GEOSCoverageCleanParams object
-typedef struct {
- double snappingDistance;
- int overlapMergeStrategy;
- double gapMaximumWidth;
-} GEOSCoverageCleanParams;
-
-// Implementation struct for the GEOSMakeValidParams object
-typedef struct {
- int method;
- int keepCollapsed;
-} GEOSMakeValidParams;
-
-
-#include "geos_c.h"
-
-/// Define this if you want operations triggering Exceptions to
-/// be printed (will use the NOTIFY channel - only implemented for GEOSUnion so far)
-///
-#undef VERBOSE_EXCEPTIONS
-
-#include
-
-/*
-#if defined(_MSC_VER)
-# define GEOS_DLL __declspec(dllexport)
-#else
-# define GEOS_DLL
-#endif
-*/
-
-// import the most frequently used definitions globally
-using geos::geom::Geometry;
-using geos::geom::LineString;
-using geos::geom::Polygon;
-using geos::geom::CoordinateSequence;
-using geos::geom::GeometryFactory;
-
-using geos::io::WKTReader;
-using geos::io::WKTWriter;
-using geos::io::WKBReader;
-using geos::io::WKBWriter;
-using geos::io::GeoJSONReader;
-using geos::io::GeoJSONWriter;
-
-
-typedef std::unique_ptr GeomPtr;
-
-//## GLOBALS ################################################
-
-// NOTE: SRID will have to be changed after geometry creation
-GEOSContextHandle_t handle = NULL;
-
-extern "C" {
-
- void
- initGEOS(GEOSMessageHandler nf, GEOSMessageHandler ef)
- {
- if(! handle) {
- handle = initGEOS_r(nf, ef);
- }
- else {
- GEOSContext_setNoticeHandler_r(handle, nf);
- GEOSContext_setErrorHandler_r(handle, ef);
- }
-
- geos::util::Interrupt::cancel();
- }
-
- void
- finishGEOS()
- {
- if(handle != NULL) {
- finishGEOS_r(handle);
- handle = NULL;
- }
- }
-
- GEOSInterruptCallback*
- GEOS_interruptRegisterCallback(GEOSInterruptCallback* cb)
- {
- return geos::util::Interrupt::registerCallback(cb);
- }
-
- void
- GEOS_interruptRequest()
- {
- geos::util::Interrupt::request();
- }
-
- void
- GEOS_interruptCancel()
- {
- geos::util::Interrupt::cancel();
- }
-
- void
- GEOSFree(void* buffer)
- {
- GEOSFree_r(handle, buffer);
- }
-
- /****************************************************************
- ** relate()-related functions
- ** return 0 = false, 1 = true, 2 = error occurred
- **
- */
- char
- GEOSDisjoint(const Geometry* g1, const Geometry* g2)
- {
- return GEOSDisjoint_r(handle, g1, g2);
- }
-
- char
- GEOSTouches(const Geometry* g1, const Geometry* g2)
- {
- return GEOSTouches_r(handle, g1, g2);
- }
-
- char
- GEOSIntersects(const Geometry* g1, const Geometry* g2)
- {
- return GEOSIntersects_r(handle, g1, g2);
- }
-
- char
- GEOSCrosses(const Geometry* g1, const Geometry* g2)
- {
- return GEOSCrosses_r(handle, g1, g2);
- }
-
- char
- GEOSWithin(const Geometry* g1, const Geometry* g2)
- {
- return GEOSWithin_r(handle, g1, g2);
- }
-
-// call g1->contains(g2)
-// returns 0 = false
-// 1 = true
-// 2 = error was trapped
- char
- GEOSContains(const Geometry* g1, const Geometry* g2)
- {
- return GEOSContains_r(handle, g1, g2);
- }
-
- char
- GEOSOverlaps(const Geometry* g1, const Geometry* g2)
- {
- return GEOSOverlaps_r(handle, g1, g2);
- }
-
- char
- GEOSCovers(const Geometry* g1, const Geometry* g2)
- {
- return GEOSCovers_r(handle, g1, g2);
- }
-
- char
- GEOSCoveredBy(const Geometry* g1, const Geometry* g2)
- {
- return GEOSCoveredBy_r(handle, g1, g2);
- }
-
-
-//-------------------------------------------------------------------
-// low-level relate functions
-//------------------------------------------------------------------
-
- char
- GEOSRelatePattern(const Geometry* g1, const Geometry* g2, const char* imPattern)
- {
- return GEOSRelatePattern_r(handle, g1, g2, imPattern);
- }
-
- char
- GEOSRelatePatternMatch(const char* intMatrix, const char* imPattern)
- {
- return GEOSRelatePatternMatch_r(handle, intMatrix, imPattern);
- }
-
- char*
- GEOSRelate(const Geometry* g1, const Geometry* g2)
- {
- return GEOSRelate_r(handle, g1, g2);
- }
-
- char*
- GEOSRelateBoundaryNodeRule(const Geometry* g1, const Geometry* g2, int bnr)
- {
- return GEOSRelateBoundaryNodeRule_r(handle, g1, g2, bnr);
- }
-
-
-//-----------------------------------------------------------------
-// isValid
-//-----------------------------------------------------------------
-
-
- char
- GEOSisValid(const Geometry* g)
- {
- return GEOSisValid_r(handle, g);
- }
-
- char*
- GEOSisValidReason(const Geometry* g)
- {
- return GEOSisValidReason_r(handle, g);
- }
-
- char
- GEOSisValidDetail(const Geometry* g, int flags,
- char** reason, Geometry** location)
- {
- return GEOSisValidDetail_r(handle, g, flags, reason, location);
- }
-
-//-----------------------------------------------------------------
-// general purpose
-//-----------------------------------------------------------------
-
- char
- GEOSEquals(const Geometry* g1, const Geometry* g2)
- {
- return GEOSEquals_r(handle, g1, g2);
- }
-
- char
- GEOSEqualsExact(const Geometry* g1, const Geometry* g2, double tolerance)
- {
- return GEOSEqualsExact_r(handle, g1, g2, tolerance);
- }
-
- char
- GEOSEqualsIdentical(const Geometry* g1, const Geometry* g2)
- {
- return GEOSEqualsIdentical_r(handle, g1, g2);
- }
-
- int
- GEOSDistance(const Geometry* g1, const Geometry* g2, double* dist)
- {
- return GEOSDistance_r(handle, g1, g2, dist);
- }
-
- char
- GEOSDistanceWithin(const Geometry* g1, const Geometry* g2, double dist)
- {
- return GEOSDistanceWithin_r(handle, g1, g2, dist);
- }
-
- int
- GEOSDistanceIndexed(const Geometry* g1, const Geometry* g2, double* dist)
- {
- return GEOSDistanceIndexed_r(handle, g1, g2, dist);
- }
-
- int
- GEOSHausdorffDistance(const Geometry* g1, const Geometry* g2, double* dist)
- {
- return GEOSHausdorffDistance_r(handle, g1, g2, dist);
- }
-
- int
- GEOSHausdorffDistanceDensify(const Geometry* g1, const Geometry* g2, double densifyFrac, double* dist)
- {
- return GEOSHausdorffDistanceDensify_r(handle, g1, g2, densifyFrac, dist);
- }
-
- int
- GEOSFrechetDistance(const Geometry* g1, const Geometry* g2, double* dist)
- {
- return GEOSFrechetDistance_r(handle, g1, g2, dist);
- }
-
- int
- GEOSFrechetDistanceDensify(const Geometry* g1, const Geometry* g2, double densifyFrac, double* dist)
- {
- return GEOSFrechetDistanceDensify_r(handle, g1, g2, densifyFrac, dist);
- }
-
- int
- GEOSArea(const Geometry* g, double* area)
- {
- return GEOSArea_r(handle, g, area);
- }
-
- int
- GEOSLength(const Geometry* g, double* length)
- {
- return GEOSLength_r(handle, g, length);
- }
-
- CoordinateSequence*
- GEOSNearestPoints(const Geometry* g1, const Geometry* g2)
- {
- return GEOSNearestPoints_r(handle, g1, g2);
- }
-
- GEOSClusterInfo*
- GEOSClusterDBSCAN(const GEOSGeometry* g, double eps, unsigned minPoints)
- {
- return GEOSClusterDBSCAN_r(handle, g, eps, minPoints);
- }
-
- GEOSClusterInfo*
- GEOSClusterGeometryDistance(const GEOSGeometry* g, double d)
- {
- return GEOSClusterGeometryDistance_r(handle, g, d);
- }
-
- GEOSClusterInfo*
- GEOSClusterGeometryIntersects(const GEOSGeometry* g)
- {
- return GEOSClusterGeometryIntersects_r(handle, g);
- }
-
- GEOSClusterInfo*
- GEOSClusterEnvelopeDistance(const GEOSGeometry* g, double d)
- {
- return GEOSClusterEnvelopeDistance_r(handle, g, d);
- }
-
- GEOSClusterInfo*
- GEOSClusterEnvelopeIntersects(const GEOSGeometry* g)
- {
- return GEOSClusterEnvelopeIntersects_r(handle, g);
- }
-
- std::size_t GEOSClusterInfo_getNumClusters(const GEOSClusterInfo* clusters)
- {
- return GEOSClusterInfo_getNumClusters_r(handle, clusters);
- }
-
- std::size_t GEOSClusterInfo_getClusterSize(const GEOSClusterInfo* clusters, size_t i)
- {
- return GEOSClusterInfo_getClusterSize_r(handle, clusters, i);
- }
-
- const std::size_t* GEOSClusterInfo_getInputsForClusterN(const GEOSClusterInfo* clusters, size_t i)
- {
- return GEOSClusterInfo_getInputsForClusterN_r(handle, clusters, i);
- }
-
- std::size_t* GEOSClusterInfo_getClustersForInputs(const GEOSClusterInfo* clusters)
- {
- return GEOSClusterInfo_getClustersForInputs_r(handle, clusters);
- }
-
- void GEOSClusterInfo_destroy(GEOSClusterInfo* info)
- {
- GEOSClusterInfo_destroy_r(handle, info);
- }
-
- Geometry*
- GEOSGeomFromWKT(const char* wkt)
- {
- return GEOSGeomFromWKT_r(handle, wkt);
- }
-
- char*
- GEOSGeomToWKT(const Geometry* g)
- {
- return GEOSGeomToWKT_r(handle, g);
- }
-
-// Remember to free the result!
- unsigned char*
- GEOSGeomToWKB_buf(const Geometry* g, std::size_t* size)
- {
- return GEOSGeomToWKB_buf_r(handle, g, size);
- }
-
- Geometry*
- GEOSGeomFromWKB_buf(const unsigned char* wkb, std::size_t size)
- {
- return GEOSGeomFromWKB_buf_r(handle, wkb, size);
- }
-
- /* Read/write wkb hex values. Returned geometries are
- owned by the caller.*/
- unsigned char*
- GEOSGeomToHEX_buf(const Geometry* g, std::size_t* size)
- {
- return GEOSGeomToHEX_buf_r(handle, g, size);
- }
-
- Geometry*
- GEOSGeomFromHEX_buf(const unsigned char* hex, std::size_t size)
- {
- return GEOSGeomFromHEX_buf_r(handle, hex, size);
- }
-
- char
- GEOSisEmpty(const Geometry* g)
- {
- return GEOSisEmpty_r(handle, g);
- }
-
- char
- GEOSisSimple(const Geometry* g)
- {
- return GEOSisSimple_r(handle, g);
- }
-
- char
- GEOSisSimpleDetail(const Geometry* g, int returnAllPoints, Geometry** result)
- {
- return GEOSisSimpleDetail_r(handle, g, returnAllPoints, result);
- }
-
- char
- GEOSisRing(const Geometry* g)
- {
- return GEOSisRing_r(handle, g);
- }
-
-
-
-//free the result of this
- char*
- GEOSGeomType(const Geometry* g)
- {
- return GEOSGeomType_r(handle, g);
- }
-
-// Return postgis geometry type index
- int
- GEOSGeomTypeId(const Geometry* g)
- {
- return GEOSGeomTypeId_r(handle, g);
- }
-
-
-
-
-//-------------------------------------------------------------------
-// GEOS functions that return geometries
-//-------------------------------------------------------------------
-
- Geometry*
- GEOSEnvelope(const Geometry* g)
- {
- return GEOSEnvelope_r(handle, g);
- }
-
- Geometry*
- GEOSIntersection(const Geometry* g1, const Geometry* g2)
- {
- return GEOSIntersection_r(handle, g1, g2);
- }
-
- Geometry*
- GEOSIntersectionPrec(const Geometry* g1, const Geometry* g2, double gridSize)
- {
- return GEOSIntersectionPrec_r(handle, g1, g2, gridSize);
- }
-
- Geometry*
- GEOSBuffer(const Geometry* g, double width, int quadrantsegments)
- {
- return GEOSBuffer_r(handle, g, width, quadrantsegments);
- }
-
- Geometry*
- GEOSBufferWithStyle(const Geometry* g, double width, int quadsegs,
- int endCapStyle, int joinStyle, double mitreLimit)
- {
- return GEOSBufferWithStyle_r(handle, g, width, quadsegs, endCapStyle,
- joinStyle, mitreLimit);
- }
-
- Geometry*
- GEOSDensify(const Geometry* g, double tolerance)
- {
- return GEOSDensify_r(handle, g, tolerance);
- }
-
-
- Geometry*
- GEOSSingleSidedBuffer(const Geometry* g, double width, int quadsegs,
- int joinStyle, double mitreLimit, int leftSide)
- {
- return GEOSSingleSidedBuffer_r(handle, g, width, quadsegs,
- joinStyle, mitreLimit, leftSide);
- }
-
- Geometry*
- GEOSOffsetCurve(const Geometry* g, double width, int quadsegs,
- int joinStyle, double mitreLimit)
- {
- return GEOSOffsetCurve_r(handle, g, width, quadsegs,
- joinStyle, mitreLimit);
- }
-
- Geometry*
- GEOSConvexHull(const Geometry* g)
- {
- return GEOSConvexHull_r(handle, g);
- }
-
- Geometry*
- GEOSConcaveHull(const Geometry* g,
- double ratio,
- unsigned int allowHoles)
-
- {
- return GEOSConcaveHull_r(handle, g, ratio, allowHoles);
- }
-
- Geometry*
- GEOSConcaveHullByLength(const Geometry* g,
- double length,
- unsigned int allowHoles)
-
- {
- return GEOSConcaveHullByLength_r(handle, g, length, allowHoles);
- }
-
- Geometry*
- GEOSPolygonHullSimplify(const Geometry* g,
- unsigned int isOuter,
- double vertexNumFraction)
- {
- return GEOSPolygonHullSimplify_r(handle, g, isOuter, vertexNumFraction);
- }
-
- Geometry*
- GEOSPolygonHullSimplifyMode(const Geometry* g,
- unsigned int isOuter,
- unsigned int parameterMode,
- double parameter)
- {
- return GEOSPolygonHullSimplifyMode_r(handle, g, isOuter, parameterMode, parameter);
- }
-
- Geometry*
- GEOSConcaveHullOfPolygons(const Geometry* g,
- double lengthRatio,
- unsigned int isTight,
- unsigned int isHolesAllowed)
- {
- return GEOSConcaveHullOfPolygons_r(handle,
- g, lengthRatio, isTight, isHolesAllowed);
- }
-
- Geometry*
- GEOSMinimumRotatedRectangle(const Geometry* g)
- {
- return GEOSMinimumRotatedRectangle_r(handle, g);
- }
-
- Geometry*
- GEOSMaximumInscribedCircle(const Geometry* g, double tolerance)
- {
- return GEOSMaximumInscribedCircle_r(handle, g, tolerance);
- }
-
- Geometry*
- GEOSLargestEmptyCircle(const Geometry* g, const Geometry* boundary, double tolerance)
- {
- return GEOSLargestEmptyCircle_r(handle, g, boundary, tolerance);
- }
-
- Geometry*
- GEOSMinimumWidth(const Geometry* g)
- {
- return GEOSMinimumWidth_r(handle, g);
- }
-
- Geometry*
- GEOSMinimumClearanceLine(const Geometry* g)
- {
- return GEOSMinimumClearanceLine_r(handle, g);
- }
-
- int
- GEOSMinimumClearance(const Geometry* g, double* d)
- {
- return GEOSMinimumClearance_r(handle, g, d);
- }
-
- Geometry*
- GEOSDifference(const Geometry* g1, const Geometry* g2)
- {
- return GEOSDifference_r(handle, g1, g2);
- }
-
- Geometry*
- GEOSDifferencePrec(const Geometry* g1, const Geometry* g2, double gridSize)
- {
- return GEOSDifferencePrec_r(handle, g1, g2, gridSize);
- }
-
- Geometry*
- GEOSBoundary(const Geometry* g)
- {
- return GEOSBoundary_r(handle, g);
- }
-
- Geometry*
- GEOSSymDifference(const Geometry* g1, const Geometry* g2)
- {
- return GEOSSymDifference_r(handle, g1, g2);
- }
-
- Geometry*
- GEOSSymDifferencePrec(const Geometry* g1, const Geometry* g2, double gridSize)
- {
- return GEOSSymDifferencePrec_r(handle, g1, g2, gridSize);
- }
-
- Geometry*
- GEOSUnion(const Geometry* g1, const Geometry* g2)
- {
- return GEOSUnion_r(handle, g1, g2);
- }
-
- Geometry*
- GEOSUnionPrec(const Geometry* g1, const Geometry* g2, double gridSize)
- {
- return GEOSUnionPrec_r(handle, g1, g2, gridSize);
- }
-
- Geometry*
- GEOSUnaryUnion(const Geometry* g)
- {
- return GEOSUnaryUnion_r(handle, g);
- }
-
- Geometry*
- GEOSUnaryUnionPrec(const Geometry* g, double gridSize)
- {
- return GEOSUnaryUnionPrec_r(handle, g, gridSize);
- }
-
- Geometry*
- GEOSCoverageUnion(const Geometry* g)
- {
- return GEOSCoverageUnion_r(handle, g);
- }
-
- Geometry*
- GEOSDisjointSubsetUnion(const Geometry* g)
- {
- return GEOSDisjointSubsetUnion_r(handle, g);
- }
-
- Geometry*
- GEOSNode(const Geometry* g)
- {
- return GEOSNode_r(handle, g);
- }
-
- Geometry*
- GEOSUnionCascaded(const Geometry* g)
- {
- return GEOSUnionCascaded_r(handle, g);
- }
-
- Geometry*
- GEOSPointOnSurface(const Geometry* g)
- {
- return GEOSPointOnSurface_r(handle, g);
- }
-
-
- Geometry*
- GEOSClipByRect(const Geometry* g, double xmin, double ymin, double xmax, double ymax)
- {
- return GEOSClipByRect_r(handle, g, xmin, ymin, xmax, ymax);
- }
-
- int
- GEOSGridIntersectionFractions(const Geometry* g, double xmin, double ymin, double xmax, double ymax,
- unsigned nx, unsigned ny, float* buf)
- {
- return GEOSGridIntersectionFractions_r(handle, g, xmin, ymin, xmax, ymax, nx, ny, buf);
- }
-
- Geometry*
- GEOSGeom_transformXY(const GEOSGeometry* g, GEOSTransformXYCallback callback, void* userdata) {
- return GEOSGeom_transformXY_r(handle, g, callback, userdata);
- }
-
-
- Geometry*
- GEOSGeom_transformXYZ(const GEOSGeometry* g, GEOSTransformXYZCallback callback, void* userdata) {
- return GEOSGeom_transformXYZ_r(handle, g, callback, userdata);
- }
-
-
-//-------------------------------------------------------------------
-// memory management functions
-//------------------------------------------------------------------
-
-
- void
- GEOSGeom_destroy(Geometry* a)
- {
- return GEOSGeom_destroy_r(handle, a);
- }
-
-
- int
- GEOSGetNumCoordinates(const Geometry* g)
- {
- return GEOSGetNumCoordinates_r(handle, g);
- }
-
- /*
- * Return -1 on exception, 0 otherwise.
- * Converts Geometry to normal form (or canonical form).
- */
- int
- GEOSNormalize(Geometry* g)
- {
- return GEOSNormalize_r(handle, g);
- }
-
- int
- GEOSOrientPolygons(Geometry* g, int exteriorCW)
- {
- return GEOSOrientPolygons_r(handle, g, exteriorCW);
- }
-
- int
- GEOSGetNumInteriorRings(const Geometry* g)
- {
- return GEOSGetNumInteriorRings_r(handle, g);
- }
-
-
-// returns -1 on error and 1 for non-multi geometries
- int
- GEOSGetNumGeometries(const Geometry* g)
- {
- return GEOSGetNumGeometries_r(handle, g);
- }
-
-
- /*
- * Call only on GEOMETRYCOLLECTION or MULTI*.
- * Return a pointer to the internal Geometry.
- */
- const Geometry*
- GEOSGetGeometryN(const Geometry* g, int n)
- {
- return GEOSGetGeometryN_r(handle, g, n);
- }
-
- /*
- * Call only on LINESTRING
- * Returns NULL on exception
- */
- Geometry*
- GEOSGeomGetPointN(const Geometry* g, int n)
- {
- return GEOSGeomGetPointN_r(handle, g, n);
- }
-
- /*
- * Call only on LINESTRING
- */
- Geometry*
- GEOSGeomGetStartPoint(const Geometry* g)
- {
- return GEOSGeomGetStartPoint_r(handle, g);
- }
-
- /*
- * Call only on LINESTRING
- */
- Geometry*
- GEOSGeomGetEndPoint(const Geometry* g)
- {
- return GEOSGeomGetEndPoint_r(handle, g);
- }
-
- /*
- * Call only on LINESTRING
- * return 2 on exception, 1 on true, 0 on false
- */
- char
- GEOSisClosed(const Geometry* g)
- {
- return GEOSisClosed_r(handle, g);
- }
-
- /*
- * Call only on LINESTRING
- * returns 0 on exception, otherwise 1
- */
- int
- GEOSGeomGetLength(const Geometry* g, double* length)
- {
- return GEOSGeomGetLength_r(handle, g, length);
- }
-
- /*
- * Call only on LINESTRING
- * returns -1 on exception
- */
- int
- GEOSGeomGetNumPoints(const Geometry* g)
- {
- return GEOSGeomGetNumPoints_r(handle, g);
- }
-
- /*
- * For POINT
- * returns 0 on exception, otherwise 1
- */
- int
- GEOSGeomGetX(const Geometry* g, double* x)
- {
- return GEOSGeomGetX_r(handle, g, x);
- }
-
- /*
- * For POINT
- * returns 0 on exception, otherwise 1
- */
- int
- GEOSGeomGetY(const Geometry* g, double* y)
- {
- return GEOSGeomGetY_r(handle, g, y);
- }
-
- /*
- * For POINT
- * returns 0 on exception, otherwise 1
- */
- int
- GEOSGeomGetZ(const Geometry* g1, double* z)
- {
- return GEOSGeomGetZ_r(handle, g1, z);
- }
-
- /*
- * For POINT
- * returns 0 on exception, otherwise 1
- */
- int
- GEOSGeomGetM(const Geometry* g1, double* m)
- {
- return GEOSGeomGetM_r(handle, g1, m);
- }
-
- /*
- * Call only on polygon
- * Return a copy of the internal Geometry.
- */
- const Geometry*
- GEOSGetExteriorRing(const Geometry* g)
- {
- return GEOSGetExteriorRing_r(handle, g);
- }
-
- /*
- * Call only on polygon
- * Return a pointer to internal storage, do not destroy it.
- */
- const Geometry*
- GEOSGetInteriorRingN(const Geometry* g, int n)
- {
- return GEOSGetInteriorRingN_r(handle, g, n);
- }
-
- Geometry*
- GEOSGetCentroid(const Geometry* g)
- {
- return GEOSGetCentroid_r(handle, g);
- }
-
- int
- GEOSHilbertCode(const GEOSGeometry *geom, const GEOSGeometry* extent,
- unsigned int level, unsigned int *code)
- {
- return GEOSHilbertCode_r(handle, geom, extent, level, code);
- }
-
- Geometry*
- GEOSMinimumBoundingCircle(const Geometry* g, double* radius, Geometry** center)
- {
- return GEOSMinimumBoundingCircle_r(handle, g, radius, center);
- }
-
- Geometry*
- GEOSGeom_createCollection(int type, Geometry** geoms, unsigned int ngeoms)
- {
- return GEOSGeom_createCollection_r(handle, type, geoms, ngeoms);
- }
-
- Geometry**
- GEOSGeom_releaseCollection(Geometry* collection, unsigned int * ngeoms)
- {
- return GEOSGeom_releaseCollection_r(handle, collection, ngeoms);
- }
-
- Geometry*
- GEOSPolygonize(const Geometry* const* g, unsigned int ngeoms)
- {
- return GEOSPolygonize_r(handle, g, ngeoms);
- }
-
- Geometry*
- GEOSPolygonize_valid(const Geometry* const* g, unsigned int ngeoms)
- {
- return GEOSPolygonize_valid_r(handle, g, ngeoms);
- }
-
- Geometry*
- GEOSPolygonizer_getCutEdges(const Geometry* const* g, unsigned int ngeoms)
- {
- return GEOSPolygonizer_getCutEdges_r(handle, g, ngeoms);
- }
-
- GEOSGeometry*
- GEOSPolygonize_full(const GEOSGeometry* input,
- GEOSGeometry** cuts, GEOSGeometry** dangles, GEOSGeometry** invalid)
- {
- return GEOSPolygonize_full_r(handle, input, cuts, dangles, invalid);
- }
-
- Geometry*
- GEOSBuildArea(const Geometry* g)
- {
- return GEOSBuildArea_r(handle, g);
- }
-
- Geometry*
- GEOSMakeValid(const Geometry* g)
- {
- return GEOSMakeValid_r(handle, g);
- }
-
- GEOSMakeValidParams*
- GEOSMakeValidParams_create()
- {
- return GEOSMakeValidParams_create_r(handle);
- }
-
- void
- GEOSMakeValidParams_destroy(GEOSMakeValidParams* parms)
- {
- return GEOSMakeValidParams_destroy_r(handle, parms);
- }
-
- int
- GEOSMakeValidParams_setMethod(
- GEOSMakeValidParams* p,
- GEOSMakeValidMethods method)
- {
- return GEOSMakeValidParams_setMethod_r(handle, p, method);
- }
-
- int
- GEOSMakeValidParams_setKeepCollapsed(
- GEOSMakeValidParams* p,
- int keepCollapsed)
- {
- return GEOSMakeValidParams_setKeepCollapsed_r(handle, p, keepCollapsed);
- }
-
- Geometry*
- GEOSMakeValidWithParams(
- const Geometry* g,
- const GEOSMakeValidParams* params)
- {
- return GEOSMakeValidWithParams_r(handle, g, params);
- }
-
- GEOSCoverageCleanParams*
- GEOSCoverageCleanParams_create()
- {
- return GEOSCoverageCleanParams_create_r(handle);
- }
-
- void
- GEOSCoverageCleanParams_destroy(
- GEOSCoverageCleanParams* params)
- {
- return GEOSCoverageCleanParams_destroy_r(handle, params);
- }
-
- int
- GEOSCoverageCleanParams_setSnappingDistance(
- GEOSCoverageCleanParams* params, double snappingDistance)
- {
- return GEOSCoverageCleanParams_setSnappingDistance_r(
- handle, params, snappingDistance);
- }
-
- int
- GEOSCoverageCleanParams_setGapMaximumWidth(
- GEOSCoverageCleanParams* params, double gapMaximumWidth)
- {
- return GEOSCoverageCleanParams_setGapMaximumWidth_r(
- handle, params, gapMaximumWidth);
- }
-
- int
- GEOSCoverageCleanParams_setOverlapMergeStrategy(
- GEOSCoverageCleanParams* params, int overlapMergeStrategy)
- {
- return GEOSCoverageCleanParams_setOverlapMergeStrategy_r(
- handle, params, overlapMergeStrategy);
- }
-
- GEOSGeometry *
- GEOSCoverageCleanWithParams(
- const GEOSGeometry* input,
- const GEOSCoverageCleanParams* params)
- {
- return GEOSCoverageCleanWithParams_r(
- handle, input, params);
- }
-
- GEOSGeometry *
- GEOSCoverageClean(
- const GEOSGeometry * input)
- {
- return GEOSCoverageClean_r(
- handle, input);
- }
-
- Geometry*
- GEOSRemoveRepeatedPoints(
- const Geometry* g,
- double tolerance)
- {
- return GEOSRemoveRepeatedPoints_r(handle, g, tolerance);
- }
-
- Geometry*
- GEOSLineMerge(const Geometry* g)
- {
- return GEOSLineMerge_r(handle, g);
- }
-
- Geometry*
- GEOSLineMergeDirected(const Geometry* g)
- {
- return GEOSLineMergeDirected_r(handle, g);
- }
-
- Geometry*
- GEOSLineSubstring(const Geometry* g, double start_fraction, double end_fraction)
- {
- return GEOSLineSubstring_r(handle, g, start_fraction, end_fraction);
- }
-
- Geometry*
- GEOSReverse(const Geometry* g)
- {
- return GEOSReverse_r(handle, g);
- }
-
- int
- GEOSGetSRID(const Geometry* g)
- {
- return GEOSGetSRID_r(handle, g);
- }
-
- void
- GEOSSetSRID(Geometry* g, int srid)
- {
- return GEOSSetSRID_r(handle, g, srid);
- }
-
- void*
- GEOSGeom_getUserData(const Geometry* g)
- {
- return GEOSGeom_getUserData_r(handle, g);
- }
-
- void
- GEOSGeom_setUserData(Geometry* g, void* userData)
- {
- return GEOSGeom_setUserData_r(handle, g, userData);
- }
-
- char
- GEOSHasZ(const Geometry* g)
- {
- return GEOSHasZ_r(handle, g);
- }
-
- char
- GEOSHasM(const Geometry* g)
- {
- return GEOSHasM_r(handle, g);
- }
-
- int
- GEOS_getWKBOutputDims()
- {
- return GEOS_getWKBOutputDims_r(handle);
- }
-
- int
- GEOS_setWKBOutputDims(int newdims)
- {
- return GEOS_setWKBOutputDims_r(handle, newdims);
- }
-
- int
- GEOS_getWKBByteOrder()
- {
- return GEOS_getWKBByteOrder_r(handle);
- }
-
- int
- GEOS_setWKBByteOrder(int byteOrder)
- {
- return GEOS_setWKBByteOrder_r(handle, byteOrder);
- }
-
- CoordinateSequence*
- GEOSCoordSeq_create(unsigned int size, unsigned int dims)
- {
- return GEOSCoordSeq_create_r(handle, size, dims);
- }
-
- CoordinateSequence*
- GEOSCoordSeq_createWithDimensions(unsigned int size, int hasZ, int hasM)
- {
- return GEOSCoordSeq_createWithDimensions_r(handle, size, hasZ, hasM);
- }
-
- CoordinateSequence*
- GEOSCoordSeq_copyFromBuffer(const double* buf, unsigned int size, int hasZ, int hasM)
- {
- return GEOSCoordSeq_copyFromBuffer_r(handle, buf, size, hasZ, hasM);
- }
-
- int
- GEOSCoordSeq_copyToBuffer(const CoordinateSequence* s, double* buf, int hasZ, int hasM)
- {
- return GEOSCoordSeq_copyToBuffer_r(handle, s, buf, hasZ, hasM);
- }
-
- CoordinateSequence*
- GEOSCoordSeq_copyFromArrays(const double* x, const double* y, const double* z, const double* m, unsigned int size)
- {
- return GEOSCoordSeq_copyFromArrays_r(handle, x, y, z, m, size);
- }
-
- int
- GEOSCoordSeq_copyToArrays(const CoordinateSequence* s, double* x, double* y, double* z, double* m)
- {
- return GEOSCoordSeq_copyToArrays_r(handle, s, x, y, z, m);
- }
-
- char
- GEOSCoordSeq_hasZ(CoordinateSequence* s)
- {
- return GEOSCoordSeq_hasZ_r(handle, s);
- }
-
- char
- GEOSCoordSeq_hasM(CoordinateSequence* s)
- {
- return GEOSCoordSeq_hasM_r(handle, s);
- }
-
- int
- GEOSCoordSeq_setOrdinate(CoordinateSequence* s, unsigned int idx, unsigned int dim, double val)
- {
- return GEOSCoordSeq_setOrdinate_r(handle, s, idx, dim, val);
- }
-
- int
- GEOSCoordSeq_setX(CoordinateSequence* s, unsigned int idx, double val)
- {
- return GEOSCoordSeq_setOrdinate(s, idx, CoordinateSequence::X, val);
- }
-
- int
- GEOSCoordSeq_setY(CoordinateSequence* s, unsigned int idx, double val)
- {
- return GEOSCoordSeq_setOrdinate(s, idx, CoordinateSequence::Y, val);
- }
-
- int
- GEOSCoordSeq_setZ(CoordinateSequence* s, unsigned int idx, double val)
- {
- return GEOSCoordSeq_setOrdinate(s, idx, CoordinateSequence::Z, val);
- }
-
- int
- GEOSCoordSeq_setM(CoordinateSequence* s, unsigned int idx, double val)
- {
- return GEOSCoordSeq_setOrdinate(s, idx, CoordinateSequence::M, val);
- }
-
- int
- GEOSCoordSeq_setXY(CoordinateSequence* s, unsigned int idx, double x, double y)
- {
- return GEOSCoordSeq_setXY_r(handle, s, idx, x, y);
- }
-
- int
- GEOSCoordSeq_setXYZ(CoordinateSequence* s, unsigned int idx, double x, double y, double z)
- {
- return GEOSCoordSeq_setXYZ_r(handle, s, idx, x, y, z);
- }
-
- CoordinateSequence*
- GEOSCoordSeq_clone(const CoordinateSequence* s)
- {
- return GEOSCoordSeq_clone_r(handle, s);
- }
-
- int
- GEOSCoordSeq_getOrdinate(const CoordinateSequence* s, unsigned int idx, unsigned int dim, double* val)
- {
- return GEOSCoordSeq_getOrdinate_r(handle, s, idx, dim, val);
- }
-
- int
- GEOSCoordSeq_getX(const CoordinateSequence* s, unsigned int idx, double* val)
- {
- return GEOSCoordSeq_getOrdinate(s, idx, CoordinateSequence::X, val);
- }
-
- int
- GEOSCoordSeq_getY(const CoordinateSequence* s, unsigned int idx, double* val)
- {
- return GEOSCoordSeq_getOrdinate(s, idx, CoordinateSequence::Y, val);
- }
-
- int
- GEOSCoordSeq_getZ(const CoordinateSequence* s, unsigned int idx, double* val)
- {
- return GEOSCoordSeq_getOrdinate(s, idx, CoordinateSequence::Z, val);
- }
-
- int
- GEOSCoordSeq_getM(const CoordinateSequence* s, unsigned int idx, double* val)
- {
- return GEOSCoordSeq_getOrdinate(s, idx, CoordinateSequence::M, val);
- }
-
- int
- GEOSCoordSeq_getXY(const CoordinateSequence* s, unsigned int idx, double* x, double* y)
- {
- return GEOSCoordSeq_getXY_r(handle, s, idx, x, y);
- }
-
- int
- GEOSCoordSeq_getXYZ(const CoordinateSequence* s, unsigned int idx, double* x, double* y, double* z)
- {
- return GEOSCoordSeq_getXYZ_r(handle, s, idx, x, y, z);
- }
-
- int
- GEOSCoordSeq_getSize(const CoordinateSequence* s, unsigned int* size)
- {
- return GEOSCoordSeq_getSize_r(handle, s, size);
- }
-
- int
- GEOSCoordSeq_getDimensions(const CoordinateSequence* s, unsigned int* dims)
- {
- return GEOSCoordSeq_getDimensions_r(handle, s, dims);
- }
-
- int
- GEOSCoordSeq_isCCW(const CoordinateSequence* s, char* is_ccw)
- {
- return GEOSCoordSeq_isCCW_r(handle, s, is_ccw);
- }
-
- void
- GEOSCoordSeq_destroy(CoordinateSequence* s)
- {
- return GEOSCoordSeq_destroy_r(handle, s);
- }
-
- const CoordinateSequence*
- GEOSGeom_getCoordSeq(const Geometry* g)
- {
- return GEOSGeom_getCoordSeq_r(handle, g);
- }
-
- Geometry*
- GEOSGeom_createPoint(CoordinateSequence* cs)
- {
- return GEOSGeom_createPoint_r(handle, cs);
- }
-
- Geometry*
- GEOSGeom_createPointFromXY(double x, double y)
- {
- return GEOSGeom_createPointFromXY_r(handle, x, y);
- }
-
- Geometry*
- GEOSGeom_createLinearRing(CoordinateSequence* cs)
- {
- return GEOSGeom_createLinearRing_r(handle, cs);
- }
-
- Geometry*
- GEOSGeom_createLineString(CoordinateSequence* cs)
- {
- return GEOSGeom_createLineString_r(handle, cs);
- }
-
- Geometry*
- GEOSGeom_createPolygon(Geometry* shell, Geometry** holes, unsigned int nholes)
- {
- return GEOSGeom_createPolygon_r(handle, shell, holes, nholes);
- }
-
- Geometry*
- GEOSGeom_createCircularString(CoordinateSequence* cs)
- {
- return GEOSGeom_createCircularString_r(handle, cs);
- }
-
- Geometry*
- GEOSGeom_createCompoundCurve(Geometry** curves, unsigned int ngeoms)
- {
- return GEOSGeom_createCompoundCurve_r(handle, curves, ngeoms);
- }
-
- Geometry*
- GEOSGeom_createCurvePolygon(Geometry* shell, Geometry** holes, unsigned int nholes)
- {
- return GEOSGeom_createCurvePolygon_r(handle, shell, holes, nholes);
- }
-
- Geometry*
- GEOSGeom_clone(const Geometry* g)
- {
- return GEOSGeom_clone_r(handle, g);
- }
-
- GEOSGeometry*
- GEOSGeom_setPrecision(const GEOSGeometry* g, double gridSize, int flags)
- {
- return GEOSGeom_setPrecision_r(handle, g, gridSize, flags);
- }
-
- double
- GEOSGeom_getPrecision(const GEOSGeometry* g)
- {
- return GEOSGeom_getPrecision_r(handle, g);
- }
-
- int
- GEOSGeom_getDimensions(const Geometry* g)
- {
- return GEOSGeom_getDimensions_r(handle, g);
- }
-
- int
- GEOSGeom_getCoordinateDimension(const Geometry* g)
- {
- return GEOSGeom_getCoordinateDimension_r(handle, g);
- }
-
- int GEOS_DLL GEOSGeom_getXMin(const GEOSGeometry* g, double* value)
- {
- return GEOSGeom_getXMin_r(handle, g, value);
- }
-
- int GEOS_DLL GEOSGeom_getYMin(const GEOSGeometry* g, double* value)
- {
- return GEOSGeom_getYMin_r(handle, g, value);
- }
-
- int GEOS_DLL GEOSGeom_getXMax(const GEOSGeometry* g, double* value)
- {
- return GEOSGeom_getXMax_r(handle, g, value);
- }
-
- int GEOS_DLL GEOSGeom_getYMax(const GEOSGeometry* g, double* value)
- {
- return GEOSGeom_getYMax_r(handle, g, value);
- }
-
- int GEOS_DLL GEOSGeom_getExtent(const GEOSGeometry* g, double* xmin, double* ymin, double* xmax, double* ymax)
- {
- return GEOSGeom_getExtent_r(handle, g, xmin, ymin, xmax, ymax);
- }
-
- Geometry*
- GEOSSimplify(const Geometry* g, double tolerance)
- {
- return GEOSSimplify_r(handle, g, tolerance);
- }
-
- Geometry*
- GEOSTopologyPreserveSimplify(const Geometry* g, double tolerance)
- {
- return GEOSTopologyPreserveSimplify_r(handle, g, tolerance);
- }
-
-
- /* WKT Reader */
- WKTReader*
- GEOSWKTReader_create()
- {
- return GEOSWKTReader_create_r(handle);
- }
-
- void
- GEOSWKTReader_destroy(WKTReader* reader)
- {
- GEOSWKTReader_destroy_r(handle, reader);
- }
-
- void
- GEOSWKTReader_setFixStructure(WKTReader* reader, char doFix)
- {
- GEOSWKTReader_setFixStructure_r(handle, reader, doFix);
- }
-
- Geometry*
- GEOSWKTReader_read(WKTReader* reader, const char* wkt)
- {
- return GEOSWKTReader_read_r(handle, reader, wkt);
- }
-
- /* WKT Writer */
- WKTWriter*
- GEOSWKTWriter_create()
- {
- return GEOSWKTWriter_create_r(handle);
- }
-
- void
- GEOSWKTWriter_destroy(WKTWriter* Writer)
- {
- GEOSWKTWriter_destroy_r(handle, Writer);
- }
-
- char*
- GEOSWKTWriter_write(WKTWriter* writer, const Geometry* geom)
- {
- return GEOSWKTWriter_write_r(handle, writer, geom);
- }
-
- void
- GEOSWKTWriter_setTrim(WKTWriter* writer, char trim)
- {
- GEOSWKTWriter_setTrim_r(handle, writer, trim);
- }
-
- void
- GEOSWKTWriter_setRoundingPrecision(WKTWriter* writer, int precision)
- {
- return GEOSWKTWriter_setRoundingPrecision_r(handle, writer, precision);
- }
-
- void
- GEOSWKTWriter_setOutputDimension(WKTWriter* writer, int dim)
- {
- GEOSWKTWriter_setOutputDimension_r(handle, writer, dim);
- }
-
- int
- GEOSWKTWriter_getOutputDimension(WKTWriter* writer)
- {
- return GEOSWKTWriter_getOutputDimension_r(handle, writer);
- }
-
- void
- GEOSWKTWriter_setOld3D(WKTWriter* writer, int useOld3D)
- {
- GEOSWKTWriter_setOld3D_r(handle, writer, useOld3D);
- }
-
- /* WKB Reader */
- WKBReader*
- GEOSWKBReader_create()
- {
- return GEOSWKBReader_create_r(handle);
- }
-
- void
- GEOSWKBReader_destroy(WKBReader* reader)
- {
- GEOSWKBReader_destroy_r(handle, reader);
- }
-
- void
- GEOSWKBReader_setFixStructure(WKBReader* reader, char doFix)
- {
- GEOSWKBReader_setFixStructure_r(handle, reader, doFix);
- }
-
- Geometry*
- GEOSWKBReader_read(WKBReader* reader, const unsigned char* wkb, std::size_t size)
- {
- return GEOSWKBReader_read_r(handle, reader, wkb, size);
- }
-
- Geometry*
- GEOSWKBReader_readHEX(WKBReader* reader, const unsigned char* hex, std::size_t size)
- {
- return GEOSWKBReader_readHEX_r(handle, reader, hex, size);
- }
-
- /* WKB Writer */
- WKBWriter*
- GEOSWKBWriter_create()
- {
- return GEOSWKBWriter_create_r(handle);
- }
-
- void
- GEOSWKBWriter_destroy(WKBWriter* Writer)
- {
- GEOSWKBWriter_destroy_r(handle, Writer);
- }
-
-
- /* The caller owns the result */
- unsigned char*
- GEOSWKBWriter_write(WKBWriter* writer, const Geometry* geom, std::size_t* size)
- {
- return GEOSWKBWriter_write_r(handle, writer, geom, size);
- }
-
- /* The caller owns the result */
- unsigned char*
- GEOSWKBWriter_writeHEX(WKBWriter* writer, const Geometry* geom, std::size_t* size)
- {
- return GEOSWKBWriter_writeHEX_r(handle, writer, geom, size);
- }
-
- int
- GEOSWKBWriter_getOutputDimension(const GEOSWKBWriter* writer)
- {
- return GEOSWKBWriter_getOutputDimension_r(handle, writer);
- }
-
- void
- GEOSWKBWriter_setOutputDimension(GEOSWKBWriter* writer, int newDimension)
- {
- GEOSWKBWriter_setOutputDimension_r(handle, writer, newDimension);
- }
-
- int
- GEOSWKBWriter_getByteOrder(const GEOSWKBWriter* writer)
- {
- return GEOSWKBWriter_getByteOrder_r(handle, writer);
- }
-
- void
- GEOSWKBWriter_setByteOrder(GEOSWKBWriter* writer, int newByteOrder)
- {
- GEOSWKBWriter_setByteOrder_r(handle, writer, newByteOrder);
- }
-
- int
- GEOSWKBWriter_getFlavor(const GEOSWKBWriter* writer)
- {
- return GEOSWKBWriter_getFlavor_r(handle, writer);
- }
-
- void
- GEOSWKBWriter_setFlavor(GEOSWKBWriter* writer, int newFlavor)
- {
- GEOSWKBWriter_setFlavor_r(handle, writer, newFlavor);
- }
-
- char
- GEOSWKBWriter_getIncludeSRID(const GEOSWKBWriter* writer)
- {
- return GEOSWKBWriter_getIncludeSRID_r(handle, writer);
- }
-
- void
- GEOSWKBWriter_setIncludeSRID(GEOSWKBWriter* writer, const char newIncludeSRID)
- {
- GEOSWKBWriter_setIncludeSRID_r(handle, writer, newIncludeSRID);
- }
-
- int
- GEOS_printDouble(double d, unsigned int precision, char *result) {
- return WKTWriter::writeTrimmedNumber(d, precision, result);
- }
-
- /* GeoJSON Reader */
- GeoJSONReader*
- GEOSGeoJSONReader_create()
- {
- return GEOSGeoJSONReader_create_r(handle);
- }
-
- void
- GEOSGeoJSONReader_destroy(GeoJSONReader* reader)
- {
- GEOSGeoJSONReader_destroy_r(handle, reader);
- }
-
- Geometry*
- GEOSGeoJSONReader_readGeometry(GeoJSONReader* reader, const char* geojson)
- {
- return GEOSGeoJSONReader_readGeometry_r(handle, reader, geojson);
- }
-
- /* GeoJSON Writer */
- GeoJSONWriter*
- GEOSGeoJSONWriter_create()
- {
- return GEOSGeoJSONWriter_create_r(handle);
- }
-
- void
- GEOSGeoJSONWriter_destroy(GEOSGeoJSONWriter* writer)
- {
- GEOSGeoJSONWriter_destroy_r(handle, writer);
- }
-
- char*
- GEOSGeoJSONWriter_writeGeometry(GEOSGeoJSONWriter* writer, const GEOSGeometry* g, int indent)
- {
- return GEOSGeoJSONWriter_writeGeometry_r(handle, writer, g, indent);
- }
-
- void
- GEOSGeoJSONWriter_setOutputDimension(GeoJSONWriter* writer, int dim)
- {
- GEOSGeoJSONWriter_setOutputDimension_r(handle, writer, dim);
- }
-
- int
- GEOSGeoJSONWriter_getOutputDimension(GeoJSONWriter* writer)
- {
- return GEOSGeoJSONWriter_getOutputDimension_r(handle, writer);
- }
-
-
-//-----------------------------------------------------------------
-// Prepared Geometry
-//-----------------------------------------------------------------
-
- const geos::geom::prep::PreparedGeometry*
- GEOSPrepare(const Geometry* g)
- {
- return GEOSPrepare_r(handle, g);
- }
-
- void
- GEOSPreparedGeom_destroy(const geos::geom::prep::PreparedGeometry* a)
- {
- GEOSPreparedGeom_destroy_r(handle, a);
- }
-
- char
- GEOSPreparedContains(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2)
- {
- return GEOSPreparedContains_r(handle, pg1, g2);
- }
-
- char
- GEOSPreparedContainsXY(const geos::geom::prep::PreparedGeometry* pg1, double x, double y)
- {
- return GEOSPreparedContainsXY_r(handle, pg1, x, y);
- }
-
- char
- GEOSPreparedContainsProperly(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2)
- {
- return GEOSPreparedContainsProperly_r(handle, pg1, g2);
- }
-
- char
- GEOSPreparedCoveredBy(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2)
- {
- return GEOSPreparedCoveredBy_r(handle, pg1, g2);
- }
-
- char
- GEOSPreparedCovers(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2)
- {
- return GEOSPreparedCovers_r(handle, pg1, g2);
- }
-
- char
- GEOSPreparedCrosses(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2)
- {
- return GEOSPreparedCrosses_r(handle, pg1, g2);
- }
-
- char
- GEOSPreparedDisjoint(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2)
- {
- return GEOSPreparedDisjoint_r(handle, pg1, g2);
- }
-
- char
- GEOSPreparedIntersects(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2)
- {
- return GEOSPreparedIntersects_r(handle, pg1, g2);
- }
-
- char
- GEOSPreparedIntersectsXY(const geos::geom::prep::PreparedGeometry* pg1, double x, double y)
- {
- return GEOSPreparedIntersectsXY_r(handle, pg1, x, y);
- }
-
- char
- GEOSPreparedOverlaps(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2)
- {
- return GEOSPreparedOverlaps_r(handle, pg1, g2);
- }
-
- char
- GEOSPreparedTouches(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2)
- {
- return GEOSPreparedTouches_r(handle, pg1, g2);
- }
-
- char
- GEOSPreparedWithin(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2)
- {
- return GEOSPreparedWithin_r(handle, pg1, g2);
- }
-
- char *
- GEOSPreparedRelate(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2)
- {
- return GEOSPreparedRelate_r(handle, pg1, g2);
- }
-
- char
- GEOSPreparedRelatePattern(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2, const char* imPattern)
- {
- return GEOSPreparedRelatePattern_r(handle, pg1, g2, imPattern);
- }
-
- CoordinateSequence*
- GEOSPreparedNearestPoints(const geos::geom::prep::PreparedGeometry* g1, const Geometry* g2)
- {
- return GEOSPreparedNearestPoints_r(handle, g1, g2);
- }
-
- int
- GEOSPreparedDistance(const geos::geom::prep::PreparedGeometry* g1, const Geometry* g2, double *dist)
- {
- return GEOSPreparedDistance_r(handle, g1, g2, dist);
- }
-
- char
- GEOSPreparedDistanceWithin(const geos::geom::prep::PreparedGeometry* g1, const Geometry* g2, double dist)
- {
- return GEOSPreparedDistanceWithin_r(handle, g1, g2, dist);
- }
-
- GEOSSTRtree*
- GEOSSTRtree_create(std::size_t nodeCapacity)
- {
- return GEOSSTRtree_create_r(handle, nodeCapacity);
- }
-
- int
- GEOSSTRtree_build(GEOSSTRtree* tree)
- {
- return GEOSSTRtree_build_r(handle, tree);
- }
-
- void
- GEOSSTRtree_insert(GEOSSTRtree* tree,
- const geos::geom::Geometry* g,
- void* item)
- {
- GEOSSTRtree_insert_r(handle, tree, g, item);
- }
-
- void
- GEOSSTRtree_query(GEOSSTRtree* tree,
- const geos::geom::Geometry* g,
- GEOSQueryCallback cb,
- void* userdata)
- {
- GEOSSTRtree_query_r(handle, tree, g, cb, userdata);
- }
-
- const GEOSGeometry*
- GEOSSTRtree_nearest(GEOSSTRtree* tree,
- const geos::geom::Geometry* g)
- {
- return GEOSSTRtree_nearest_r(handle, tree, g);
- }
-
- const void* GEOSSTRtree_nearest_generic(GEOSSTRtree* tree,
- const void* item,
- const GEOSGeometry* itemEnvelope,
- GEOSDistanceCallback distancefn,
- void* userdata)
- {
- return GEOSSTRtree_nearest_generic_r(handle, tree, item, itemEnvelope, distancefn, userdata);
- }
-
- void
- GEOSSTRtree_iterate(GEOSSTRtree* tree,
- GEOSQueryCallback callback,
- void* userdata)
- {
- GEOSSTRtree_iterate_r(handle, tree, callback, userdata);
- }
-
- char
- GEOSSTRtree_remove(GEOSSTRtree* tree,
- const geos::geom::Geometry* g,
- void* item)
- {
- return GEOSSTRtree_remove_r(handle, tree, g, item);
- }
-
- void
- GEOSSTRtree_destroy(GEOSSTRtree* tree)
- {
- GEOSSTRtree_destroy_r(handle, tree);
- }
-
- double
- GEOSProject(const geos::geom::Geometry* g,
- const geos::geom::Geometry* p)
- {
- return GEOSProject_r(handle, g, p);
- }
-
- geos::geom::Geometry*
- GEOSInterpolate(const geos::geom::Geometry* g,
- double d)
- {
- return GEOSInterpolate_r(handle, g, d);
- }
-
- double
- GEOSProjectNormalized(const geos::geom::Geometry* g,
- const geos::geom::Geometry* p)
- {
- return GEOSProjectNormalized_r(handle, g, p);
- }
-
- geos::geom::Geometry*
- GEOSInterpolateNormalized(const geos::geom::Geometry* g,
- double d)
- {
- return GEOSInterpolateNormalized_r(handle, g, d);
- }
-
- geos::geom::Geometry*
- GEOSGeom_extractUniquePoints(const geos::geom::Geometry* g)
- {
- return GEOSGeom_extractUniquePoints_r(handle, g);
- }
-
- geos::geom::Geometry*
- GEOSGeom_createEmptyCollection(int type)
- {
- return GEOSGeom_createEmptyCollection_r(handle, type);
- }
-
- geos::geom::Geometry*
- GEOSGeom_createEmptyPoint()
- {
- return GEOSGeom_createEmptyPoint_r(handle);
- }
-
- geos::geom::Geometry*
- GEOSGeom_createEmptyLineString()
- {
- return GEOSGeom_createEmptyLineString_r(handle);
- }
-
- geos::geom::Geometry*
- GEOSGeom_createEmptyPolygon()
- {
- return GEOSGeom_createEmptyPolygon_r(handle);
- }
-
- geos::geom::Geometry*
- GEOSGeom_createEmptyCircularString()
- {
- return GEOSGeom_createEmptyCircularString_r(handle);
- }
-
- geos::geom::Geometry*
- GEOSGeom_createEmptyCompoundCurve()
- {
- return GEOSGeom_createEmptyCompoundCurve_r(handle);
- }
-
- geos::geom::Geometry*
- GEOSGeom_createEmptyCurvePolygon()
- {
- return GEOSGeom_createEmptyCurvePolygon_r(handle);
- }
-
- geos::geom::Geometry*
- GEOSGeom_createRectangle(double xmin, double ymin, double xmax,
- double ymax)
- {
- return GEOSGeom_createRectangle_r(handle, xmin, ymin, xmax, ymax);
- }
-
- int
- GEOSOrientationIndex(double Ax, double Ay, double Bx, double By,
- double Px, double Py)
- {
- return GEOSOrientationIndex_r(handle, Ax, Ay, Bx, By, Px, Py);
- }
-
- GEOSGeometry*
- GEOSSharedPaths(const GEOSGeometry* g1, const GEOSGeometry* g2)
- {
- return GEOSSharedPaths_r(handle, g1, g2);
- }
-
- GEOSGeometry*
- GEOSSnap(const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance)
- {
- return GEOSSnap_r(handle, g1, g2, tolerance);
- }
-
- GEOSBufferParams*
- GEOSBufferParams_create()
- {
- return GEOSBufferParams_create_r(handle);
- }
-
- void
- GEOSBufferParams_destroy(GEOSBufferParams* p)
- {
- return GEOSBufferParams_destroy_r(handle, p);
- }
-
- int
- GEOSBufferParams_setEndCapStyle(GEOSBufferParams* p, int style)
- {
- return GEOSBufferParams_setEndCapStyle_r(handle, p, style);
- }
-
- int
- GEOSBufferParams_setJoinStyle(GEOSBufferParams* p, int joinStyle)
- {
- return GEOSBufferParams_setJoinStyle_r(handle, p, joinStyle);
- }
-
- int
- GEOSBufferParams_setMitreLimit(GEOSBufferParams* p, double l)
- {
- return GEOSBufferParams_setMitreLimit_r(handle, p, l);
- }
-
- int
- GEOSBufferParams_setQuadrantSegments(GEOSBufferParams* p, int joinStyle)
- {
- return GEOSBufferParams_setQuadrantSegments_r(handle, p, joinStyle);
- }
-
- int
- GEOSBufferParams_setSingleSided(GEOSBufferParams* p, int singleSided)
- {
- return GEOSBufferParams_setSingleSided_r(handle, p, singleSided);
- }
-
- Geometry*
- GEOSBufferWithParams(const Geometry* g, const GEOSBufferParams* p, double w)
- {
- return GEOSBufferWithParams_r(handle, g, p, w);
- }
-
- Geometry*
- GEOSDelaunayTriangulation(const Geometry* g, double tolerance, int onlyEdges)
- {
- return GEOSDelaunayTriangulation_r(handle, g, tolerance, onlyEdges);
- }
-
- Geometry*
- GEOSConstrainedDelaunayTriangulation(const Geometry* g)
- {
- return GEOSConstrainedDelaunayTriangulation_r(handle, g);
- }
-
- Geometry*
- GEOSVoronoiDiagram(const Geometry* g, const Geometry* env, double tolerance, int flags)
- {
- return GEOSVoronoiDiagram_r(handle, g, env, tolerance, flags);
- }
-
- int
- GEOSSegmentIntersection(double ax0, double ay0, double ax1, double ay1,
- double bx0, double by0, double bx1, double by1,
- double* cx, double* cy)
- {
- return GEOSSegmentIntersection_r(handle,
- ax0, ay0, ax1, ay1,
- bx0, by0, bx1, by1,
- cx, cy);
- }
-
- int
- GEOSCoverageIsValid(
- const Geometry* input,
- double gapWidth,
- Geometry** invalidEdges)
- {
- return GEOSCoverageIsValid_r(handle, input, gapWidth, invalidEdges);
- }
-
- Geometry*
- GEOSCoverageSimplifyVW(const Geometry* input, double tolerance, int preserveBoundary)
- {
- return GEOSCoverageSimplifyVW_r(handle, input, tolerance, preserveBoundary);
- }
-
-
-} /* extern "C" */
diff --git a/Sources/geos/capi/geos_ts_c.cpp b/Sources/geos/capi/geos_ts_c.cpp
deleted file mode 100644
index f4690f0..0000000
--- a/Sources/geos/capi/geos_ts_c.cpp
+++ /dev/null
@@ -1,4759 +0,0 @@
-/************************************************************************
- *
- *
- * C-Wrapper for GEOS library
- *
- * Copyright (C) 2005-2006 Refractions Research Inc.
- * Copyright (C) 2010-2012 Sandro Santilli
- * Copyright (C) 2016-2021 Daniel Baston
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation.
- * See the COPYING file for more information.
- *
- * Author: Sandro Santilli
- * Thread Safety modifications: Chuck Thibert
- *
- ***********************************************************************/
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-// This should go away
-#include // finite
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#ifdef _MSC_VER
-#pragma warning(disable : 4099)
-#endif
-
-// Some extra magic to make type declarations in geos_c.h work -
-// for cross-checking of types in header.
-// NOTE: the below defines or struct definition must be kept in exact
-// sync between geos_c.cpp and geos_ts_c.cpp to avoid C++ One Definition Rule
-// violations.
-#define GEOSGeometry geos::geom::Geometry
-#define GEOSPreparedGeometry geos::geom::prep::PreparedGeometry
-#define GEOSClusterInfo geos::operation::cluster::Clusters
-#define GEOSCoordSequence geos::geom::CoordinateSequence
-#define GEOSBufferParams geos::operation::buffer::BufferParameters
-#define GEOSSTRtree geos::index::strtree::TemplateSTRtree
-#define GEOSWKTReader geos::io::WKTReader
-#define GEOSWKTWriter geos::io::WKTWriter
-#define GEOSWKBReader geos::io::WKBReader
-#define GEOSWKBWriter geos::io::WKBWriter
-#define GEOSGeoJSONReader geos::io::GeoJSONReader
-#define GEOSGeoJSONWriter geos::io::GeoJSONWriter
-
-// Implementation struct for the GEOSCoverageCleanParams object
-typedef struct {
- double snappingDistance;
- int overlapMergeStrategy;
- double gapMaximumWidth;
-} GEOSCoverageCleanParams;
-
-// Implementation struct for the GEOSMakeValidParams object
-typedef struct {
- int method;
- int keepCollapsed;
-} GEOSMakeValidParams;
-
-#include "geos_c.h"
-
-// Intentional, to allow non-standard C elements like C99 functions to be
-// imported through C++ headers of C library, like .
-using namespace std;
-
-/// Define this if you want operations triggering Exceptions to
-/// be printed.
-/// (will use the NOTIFY channel - only implemented for GEOSUnion so far)
-///
-#undef VERBOSE_EXCEPTIONS
-
-#include
-#include
-
-
-// import the most frequently used definitions globally
-using geos::geom::Coordinate;
-using geos::geom::CoordinateXY;
-using geos::geom::CoordinateXYM;
-using geos::geom::CoordinateXYZM;
-using geos::geom::CoordinateSequence;
-using geos::geom::Curve;
-using geos::geom::Envelope;
-using geos::geom::Geometry;
-using geos::geom::GeometryCollection;
-using geos::geom::GeometryFactory;
-using geos::geom::LineString;
-using geos::geom::LinearRing;
-using geos::geom::MultiCurve;
-using geos::geom::MultiLineString;
-using geos::geom::MultiPolygon;
-using geos::geom::Point;
-using geos::geom::Polygon;
-using geos::geom::PrecisionModel;
-using geos::geom::SimpleCurve;
-using geos::geom::Surface;
-
-using geos::geom::prep::PreparedGeometry;
-
-using geos::io::WKTReader;
-using geos::io::WKTWriter;
-using geos::io::WKBReader;
-using geos::io::WKBWriter;
-using geos::io::GeoJSONReader;
-using geos::io::GeoJSONWriter;
-
-using geos::algorithm::distance::DiscreteFrechetDistance;
-using geos::algorithm::distance::DiscreteHausdorffDistance;
-using geos::algorithm::hull::ConcaveHull;
-using geos::algorithm::hull::ConcaveHullOfPolygons;
-
-using geos::operation::buffer::BufferBuilder;
-using geos::operation::buffer::BufferParameters;
-using geos::operation::buffer::OffsetCurve;
-using geos::operation::cluster::Clusters;
-using geos::operation::distance::IndexedFacetDistance;
-using geos::operation::geounion::CascadedPolygonUnion;
-using geos::operation::overlayng::OverlayNG;
-using geos::operation::overlayng::UnaryUnionNG;
-using geos::operation::overlayng::OverlayNGRobust;
-using geos::operation::relateng::RelateNG;
-using geos::operation::valid::TopologyValidationError;
-
-using geos::precision::GeometryPrecisionReducer;
-
-using geos::simplify::PolygonHullSimplifier;
-
-using geos::util::IllegalArgumentException;
-
-typedef struct GEOSContextHandle_HS {
- const GeometryFactory* geomFactory;
- char msgBuffer[1024];
- GEOSMessageHandler noticeMessageOld;
- GEOSMessageHandler_r noticeMessageNew;
- void* noticeData;
- GEOSMessageHandler errorMessageOld;
- GEOSMessageHandler_r errorMessageNew;
- GEOSContextInterruptCallback* interrupt_cb;
- void* interrupt_cb_data;
- void* errorData;
- uint8_t WKBOutputDims;
- int WKBByteOrder;
- int initialized;
- std::unique_ptr point2d;
-
- GEOSContextHandle_HS()
- :
- geomFactory(nullptr),
- noticeMessageOld(nullptr),
- noticeMessageNew(nullptr),
- noticeData(nullptr),
- errorMessageOld(nullptr),
- errorMessageNew(nullptr),
- interrupt_cb(nullptr),
- interrupt_cb_data(nullptr),
- errorData(nullptr),
- point2d(nullptr)
- {
- memset(msgBuffer, 0, sizeof(msgBuffer));
- geomFactory = GeometryFactory::getDefaultInstance();
- point2d = geomFactory->createPoint(CoordinateXY{0, 0});
- WKBOutputDims = 2;
- WKBByteOrder = getMachineByteOrder();
- setNoticeHandler(nullptr);
- setErrorHandler(nullptr);
- initialized = 1;
- }
-
- GEOSMessageHandler
- setNoticeHandler(GEOSMessageHandler nf)
- {
- GEOSMessageHandler f = noticeMessageOld;
- noticeMessageOld = nf;
- noticeMessageNew = nullptr;
- noticeData = nullptr;
-
- return f;
- }
-
- GEOSMessageHandler
- setErrorHandler(GEOSMessageHandler nf)
- {
- GEOSMessageHandler f = errorMessageOld;
- errorMessageOld = nf;
- errorMessageNew = nullptr;
- errorData = nullptr;
-
- return f;
- }
-
- GEOSMessageHandler_r
- setNoticeHandler(GEOSMessageHandler_r nf, void* userData)
- {
- GEOSMessageHandler_r f = noticeMessageNew;
- noticeMessageOld = nullptr;
- noticeMessageNew = nf;
- noticeData = userData;
-
- return f;
- }
-
- GEOSMessageHandler_r
- setErrorHandler(GEOSMessageHandler_r ef, void* userData)
- {
- GEOSMessageHandler_r f = errorMessageNew;
- errorMessageOld = nullptr;
- errorMessageNew = ef;
- errorData = userData;
-
- return f;
- }
-
- GEOSContextInterruptCallback*
- setInterruptHandler(GEOSContextInterruptCallback* cb, void* userData)
- {
- auto old = interrupt_cb;
- interrupt_cb = cb;
- interrupt_cb_data = userData;
- return old;
- }
-
- void
- NOTICE_MESSAGE(GEOS_PRINTF_FORMAT const char *fmt, ...) GEOS_PRINTF_FORMAT_ATTR(2, 3)
- {
- if(nullptr == noticeMessageOld && nullptr == noticeMessageNew) {
- return;
- }
-
- va_list args;
- va_start(args, fmt);
- #ifdef __MINGW32__
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
- #endif
- int result = vsnprintf(msgBuffer, sizeof(msgBuffer) - 1, fmt, args);
- #ifdef __MINGW32__
- #pragma GCC diagnostic pop
- #endif
- va_end(args);
-
- if(result > 0) {
- if(noticeMessageOld) {
- noticeMessageOld("%s", msgBuffer);
- }
- else {
- noticeMessageNew(msgBuffer, noticeData);
- }
- }
- }
-
- void
- ERROR_MESSAGE(GEOS_PRINTF_FORMAT const char *fmt, ...) GEOS_PRINTF_FORMAT_ATTR(2, 3)
- {
- if(nullptr == errorMessageOld && nullptr == errorMessageNew) {
- return;
- }
-
- va_list args;
- va_start(args, fmt);
- #ifdef __MINGW32__
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
- #endif
- int result = vsnprintf(msgBuffer, sizeof(msgBuffer) - 1, fmt, args);
- #ifdef __MINGW32__
- #pragma GCC diagnostic pop
- #endif
- va_end(args);
-
- if(result > 0) {
- if(errorMessageOld) {
- errorMessageOld("%s", msgBuffer);
- }
- else {
- errorMessageNew(msgBuffer, errorData);
- }
- }
- }
-} GEOSContextHandleInternal_t;
-
-// CAPI_ItemVisitor is used internally by the CAPI STRtree
-// wrappers. It's defined here just to keep it out of the
-// extern "C" block.
-class CAPI_ItemVisitor : public geos::index::ItemVisitor {
- GEOSQueryCallback callback;
- void* userdata;
-public:
- CAPI_ItemVisitor(GEOSQueryCallback cb, void* ud)
- : ItemVisitor(), callback(cb), userdata(ud) {}
-
- void operator()(void* item) {
- callback(item, userdata);
- }
-
- void
- visitItem(void* item) override
- {
- callback(item, userdata);
- }
-};
-
-
-//## PROTOTYPES #############################################
-
-extern "C" const char GEOS_DLL* GEOSjtsport();
-extern "C" char GEOS_DLL* GEOSasText(Geometry* g1);
-
-
-namespace { // anonymous
-
-char*
-gstrdup_s(const char* str, const std::size_t size)
-{
- char* out = static_cast(malloc(size + 1));
- if(nullptr != out) {
- // as no strlen call necessary, memcpy may be faster than strcpy
- std::memcpy(out, str, size + 1);
- }
-
- assert(nullptr != out);
-
- // we haven't been checking allocation before ticket #371
- if(nullptr == out) {
- throw(std::runtime_error("Failed to allocate memory for duplicate string"));
- }
-
- return out;
-}
-
-char*
-gstrdup(std::string const& str)
-{
- return gstrdup_s(str.c_str(), str.size());
-}
-
-struct InterruptManager {
- InterruptManager(GEOSContextHandle_t handle) :
- cb(handle->interrupt_cb),
- cb_data(handle->interrupt_cb_data) {
- if (cb) {
- geos::util::CurrentThreadInterrupt::registerCallback(cb, cb_data);
- }
- }
-
- ~InterruptManager() {
- if (cb != nullptr) {
- geos::util::CurrentThreadInterrupt::registerCallback(nullptr, nullptr);
- }
- }
-
- GEOSContextInterruptCallback* cb;
- void* cb_data;
-};
-
-struct NotInterruptible {
- NotInterruptible(GEOSContextHandle_t handle) {
- (void) handle;
- }
-};
-
-} // namespace anonymous
-
-// Execute a lambda, using the given context handle to process errors.
-// Return errval on error.
-// Errval should be of the type returned by f, unless f returns a bool in which case we promote to char.
-template
-inline auto execute(
- GEOSContextHandle_t extHandle,
- typename std::conditional()()),bool>::value,
- char,
- decltype(std::declval()())>::type errval,
- F&& f) -> decltype(errval) {
- if (extHandle == nullptr) {
- throw std::runtime_error("GEOS context handle is uninitialized, call initGEOS");
- }
-
- GEOSContextHandleInternal_t* handle = reinterpret_cast(extHandle);
- if (!handle->initialized) {
- return errval;
- }
-
- InterruptManagerType ic(handle);
-
- try {
- return f();
- } catch (const std::exception& e) {
- handle->ERROR_MESSAGE("%s", e.what());
- } catch (...) {
- handle->ERROR_MESSAGE("Unknown exception thrown");
- }
-
- return errval;
-}
-
-// Execute a lambda, using the given context handle to process errors.
-// Return nullptr on error.
-template()())>::value, std::nullptr_t>::type = nullptr>
-inline auto execute(GEOSContextHandle_t extHandle, F&& f) -> decltype(f()) {
- if (extHandle == nullptr) {
- throw std::runtime_error("context handle is uninitialized, call initGEOS");
- }
-
- GEOSContextHandleInternal_t* handle = reinterpret_cast(extHandle);
- if (!handle->initialized) {
- return nullptr;
- }
-
- InterruptManagerType ic(handle);
-
- try {
- return f();
- } catch (const std::exception& e) {
- handle->ERROR_MESSAGE("%s", e.what());
- } catch (...) {
- handle->ERROR_MESSAGE("Unknown exception thrown");
- }
-
- return nullptr;
-}
-
-// Execute a lambda, using the given context handle to process errors.
-// No return value.
-template()())>::value, std::nullptr_t>::type = nullptr>
-inline void execute(GEOSContextHandle_t extHandle, F&& f) {
- GEOSContextHandleInternal_t* handle = reinterpret_cast(extHandle);
-
- if (handle != nullptr) {
- InterruptManagerType ic(handle);
- }
-
- try {
- f();
- } catch (const std::exception& e) {
- handle->ERROR_MESSAGE("%s", e.what());
- } catch (...) {
- handle->ERROR_MESSAGE("Unknown exception thrown");
- }
-}
-
-extern "C" {
-
- GEOSContextHandle_t
- initGEOS_r(GEOSMessageHandler nf, GEOSMessageHandler ef)
- {
- GEOSContextHandle_t handle = GEOS_init_r();
-
- if(nullptr != handle) {
- GEOSContext_setNoticeHandler_r(handle, nf);
- GEOSContext_setErrorHandler_r(handle, ef);
- }
-
- return handle;
- }
-
- GEOSContextHandle_t
- GEOS_init_r()
- {
- GEOSContextHandleInternal_t* handle = new GEOSContextHandleInternal_t();
-
- geos::util::Interrupt::cancel();
-
- return static_cast(handle);
- }
-
- GEOSMessageHandler
- GEOSContext_setNoticeHandler_r(GEOSContextHandle_t extHandle, GEOSMessageHandler nf)
- {
- GEOSContextHandleInternal_t* handle = reinterpret_cast(extHandle);
- if(0 == handle->initialized) {
- return nullptr;
- }
-
- return handle->setNoticeHandler(nf);
- }
-
- GEOSMessageHandler
- GEOSContext_setErrorHandler_r(GEOSContextHandle_t extHandle, GEOSMessageHandler nf)
- {
- GEOSContextHandleInternal_t* handle = reinterpret_cast(extHandle);
- if(0 == handle->initialized) {
- return nullptr;
- }
-
- return handle->setErrorHandler(nf);
- }
-
- GEOSMessageHandler_r
- GEOSContext_setNoticeMessageHandler_r(GEOSContextHandle_t extHandle, GEOSMessageHandler_r nf, void* userData)
- {
- GEOSContextHandleInternal_t* handle = reinterpret_cast(extHandle);
- if(0 == handle->initialized) {
- return nullptr;
- }
-
- return handle->setNoticeHandler(nf, userData);
- }
-
- GEOSMessageHandler_r
- GEOSContext_setErrorMessageHandler_r(GEOSContextHandle_t extHandle, GEOSMessageHandler_r ef, void* userData)
- {
- GEOSContextHandleInternal_t* handle = reinterpret_cast(extHandle);
- if(0 == handle->initialized) {
- return nullptr;
- }
-
- return handle->setErrorHandler(ef, userData);
- }
-
- GEOSContextInterruptCallback*
- GEOSContext_setInterruptCallback_r(GEOSContextHandle_t extHandle, GEOSContextInterruptCallback* cb, void* userData)
- {
- GEOSContextHandleInternal_t* handle = reinterpret_cast(extHandle);
- if(0 == handle->initialized) {
- return nullptr;
- }
-
- return handle->setInterruptHandler(cb, userData);
- }
-
- void
- finishGEOS_r(GEOSContextHandle_t extHandle)
- {
- // Fix up freeing handle w.r.t. malloc above
- delete extHandle;
- extHandle = nullptr;
- }
-
- void
- GEOS_finish_r(GEOSContextHandle_t extHandle)
- {
- finishGEOS_r(extHandle);
- }
-
- void
- GEOSFree_r(GEOSContextHandle_t extHandle, void* buffer)
- {
- assert(nullptr != extHandle);
- geos::ignore_unused_variable_warning(extHandle);
-
- free(buffer);
- }
-
-//-----------------------------------------------------------
-// relate()-related functions
-// return 0 = false, 1 = true, 2 = error occurred
-//-----------------------------------------------------------
-
- char
- GEOSDisjoint_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
- {
- return execute(extHandle, 2, [&]() {
- return g1->disjoint(g2);
- });
- }
-
- char
- GEOSTouches_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
- {
- return execute(extHandle, 2, [&]() {
- return g1->touches(g2);
- });
- }
-
- char
- GEOSIntersects_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
- {
- return execute(extHandle, 2, [&]() {
- return g1->intersects(g2);
- });
- }
-
- char
- GEOSCrosses_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
- {
- return execute(extHandle, 2, [&]() {
- return g1->crosses(g2);
- });
- }
-
- char
- GEOSWithin_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
- {
- return execute(extHandle, 2, [&]() {
- return g1->within(g2);
- });
- }
-
- char
- GEOSContains_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
- {
- return execute(extHandle, 2, [&]() {
- return g1->contains(g2);
- });
- }
-
- char
- GEOSOverlaps_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
- {
- return execute(extHandle, 2, [&]() {
- return g1->overlaps(g2);
- });
- }
-
- char
- GEOSCovers_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
- {
- return execute(extHandle, 2, [&]() {
- return g1->covers(g2);
- });
- }
-
- char
- GEOSCoveredBy_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
- {
- return execute(extHandle, 2, [&]() {
- return g1->coveredBy(g2);
- });
- }
-
- char
- GEOSEquals_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
- {
- return execute(extHandle, 2, [&]() {
- return g1->equals(g2);
- });
- }
-
-
-//-------------------------------------------------------------------
-// low-level relate functions
-//------------------------------------------------------------------
-
- char
- GEOSRelatePattern_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, const char* imPattern)
- {
- return execute(extHandle, 2, [&]() {
- std::string s(imPattern);
- return g1->relate(g2, s);
- });
- }
-
- char
- GEOSRelatePatternMatch_r(GEOSContextHandle_t extHandle, const char* intMatrix,
- const char* imPattern)
- {
- return execute(extHandle, 2, [&]() {
- using geos::geom::IntersectionMatrix;
-
- std::string m(intMatrix);
- std::string p(imPattern);
- IntersectionMatrix im(m);
-
- return im.matches(p);
- });
- }
-
- char*
- GEOSRelate_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
- {
- return execute(extHandle, [&]() {
- using geos::geom::IntersectionMatrix;
-
- auto im = g1->relate(g2);
- if(im == nullptr) {
- return (char*) nullptr;
- }
-
- return gstrdup(im->toString());
- });
- }
-
- char*
- GEOSRelateBoundaryNodeRule_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, int bnr)
- {
- using geos::operation::relate::RelateOp;
- using geos::geom::IntersectionMatrix;
- using geos::algorithm::BoundaryNodeRule;
-
- return execute(extHandle, [&]() -> char* {
- std::unique_ptr im;
-
- switch (bnr) {
- case GEOSRELATE_BNR_MOD2: /* same as OGC */
- im = RelateNG::relate(g1, g2,
- BoundaryNodeRule::getBoundaryRuleMod2());
- break;
- case GEOSRELATE_BNR_ENDPOINT:
- im = RelateNG::relate(g1, g2,
- BoundaryNodeRule::getBoundaryEndPoint());
- break;
- case GEOSRELATE_BNR_MULTIVALENT_ENDPOINT:
- im = RelateNG::relate(g1, g2,
- BoundaryNodeRule::getBoundaryMultivalentEndPoint());
- break;
- case GEOSRELATE_BNR_MONOVALENT_ENDPOINT:
- im = RelateNG::relate(g1, g2,
- BoundaryNodeRule::getBoundaryMonovalentEndPoint());
- break;
- default:
- std::ostringstream ss;
- ss << "Invalid boundary node rule " << bnr;
- throw std::runtime_error(ss.str());
- }
-
- if(!im) {
- return nullptr;
- }
-
- char* result = gstrdup(im->toString());
-
- return result;
- });
- }
-
-
-
-//-----------------------------------------------------------------
-// isValid
-//-----------------------------------------------------------------
-
-
- char
- GEOSisValid_r(GEOSContextHandle_t extHandle, const Geometry* g1)
- {
- return execute(extHandle, 2, [&]() {
- GEOSContextHandleInternal_t* handle = reinterpret_cast(extHandle);
-
- using geos::operation::valid::IsValidOp;
-
- IsValidOp ivo(g1);
- const TopologyValidationError* err = ivo.getValidationError();
-
- if(err) {
- handle->NOTICE_MESSAGE("%s", err->toString().c_str());
- return false;
- }
- else {
- return true;
- }
- });
- }
-
- char*
- GEOSisValidReason_r(GEOSContextHandle_t extHandle, const Geometry* g1)
- {
- return execute(extHandle, [&]() {
- using geos::operation::valid::IsValidOp;
-
- char* result = nullptr;
- char const* const validstr = "Valid Geometry";
-
- IsValidOp ivo(g1);
- const TopologyValidationError* err = ivo.getValidationError();
-
- if(err) {
- std::ostringstream ss;
- ss.precision(15);
- ss << err->getCoordinate();
- const std::string errloc = ss.str();
- std::string errmsg(err->getMessage());
- errmsg += "[" + errloc + "]";
- result = gstrdup(errmsg);
- }
- else {
- result = gstrdup(std::string(validstr));
- }
-
- return result;
- });
- }
-
- char
- GEOSisValidDetail_r(GEOSContextHandle_t extHandle, const Geometry* g,
- int flags, char** reason, Geometry** location)
- {
- using geos::operation::valid::IsValidOp;
-
- return execute(extHandle, 2, [&]() {
- IsValidOp ivo(g);
- if(flags & GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE) {
- ivo.setSelfTouchingRingFormingHoleValid(true);
- }
- const TopologyValidationError* err = ivo.getValidationError();
- if(err != nullptr) {
- if(location) {
- *location = g->getFactory()->createPoint(err->getCoordinate()).release();
- }
- if(reason) {
- std::string errmsg(err->getMessage());
- *reason = gstrdup(errmsg);
- }
- return false;
- }
-
- if(location) {
- *location = nullptr;
- }
- if(reason) {
- *reason = nullptr;
- }
- return true; /* valid */
-
- });
- }
-
-//-----------------------------------------------------------------
-// general purpose
-//-----------------------------------------------------------------
-
- char
- GEOSEqualsExact_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double tolerance)
- {
- return execute(extHandle, 2, [&]() {
- return g1->equalsExact(g2, tolerance);
- });
- }
-
- char
- GEOSEqualsIdentical_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
- {
- return execute(extHandle, 2, [&]() {
- return g1->equalsIdentical(g2);
- });
- }
-
- int
- GEOSDistance_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double* dist)
- {
- return execute(extHandle, 0, [&]() {
- *dist = g1->distance(g2);
- return 1;
- });
- }
-
- char
- GEOSDistanceWithin_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double dist)
- {
- return execute(extHandle, 2, [&]() {
- return g1->isWithinDistance(g2, dist);
- });
- }
-
- int
- GEOSDistanceIndexed_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double* dist)
- {
- return execute(extHandle, 0, [&]() {
- *dist = IndexedFacetDistance::distance(g1, g2);
- return 1;
- });
- }
-
- int
- GEOSHausdorffDistance_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double* dist)
- {
- return execute(extHandle, 0, [&]() {
- *dist = DiscreteHausdorffDistance::distance(*g1, *g2);
- return 1;
- });
- }
-
- int
- GEOSHausdorffDistanceDensify_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2,
- double densifyFrac, double* dist)
- {
- return execute(extHandle, 0, [&]() {
- *dist = DiscreteHausdorffDistance::distance(*g1, *g2, densifyFrac);
- return 1;
- });
- }
-
- int
- GEOSFrechetDistance_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double* dist)
- {
- return execute(extHandle, 0, [&]() {
- *dist = DiscreteFrechetDistance::distance(*g1, *g2);
- return 1;
- });
- }
-
- int
- GEOSFrechetDistanceDensify_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double densifyFrac,
- double* dist)
- {
- return execute(extHandle, 0, [&]() {
- *dist = DiscreteFrechetDistance::distance(*g1, *g2, densifyFrac);
- return 1;
- });
- }
-
- int
- GEOSArea_r(GEOSContextHandle_t extHandle, const Geometry* g, double* area)
- {
- return execute(extHandle, 0, [&]() {
- *area = g->getArea();
- return 1;
- });
- }
-
- int
- GEOSLength_r(GEOSContextHandle_t extHandle, const Geometry* g, double* length)
- {
- return execute(extHandle, 0, [&]() {
- *length = g->getLength();
- return 1;
- });
- }
-
- CoordinateSequence*
- GEOSNearestPoints_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
- {
- return execute(extHandle, [&]() -> CoordinateSequence* {
- if(g1->isEmpty() || g2->isEmpty()) {
- return nullptr;
- }
- return geos::operation::distance::DistanceOp::nearestPoints(g1, g2).release();
- });
- }
-
- static Clusters* capi_clusters(const Geometry* g,
- geos::operation::cluster::AbstractClusterFinder& finder)
- {
- std::vector input{g->getNumGeometries()};
- for (std::size_t i = 0; i < input.size(); i++) {
- input[i] = g->getGeometryN(i);
- }
-
- return new Clusters(finder.cluster(input));
- }
-
- Clusters*
- GEOSClusterDBSCAN_r(GEOSContextHandle_t extHandle, const Geometry* g, double eps, unsigned minPoints)
- {
- return execute(extHandle, [&]() {
- geos::operation::cluster::DBSCANClusterFinder finder(eps, minPoints);
-
- return capi_clusters(g, finder);
- });
- }
-
- Clusters*
- GEOSClusterGeometryIntersects_r(GEOSContextHandle_t extHandle, const Geometry* g)
- {
- return execute(extHandle, [&]() {
- geos::operation::cluster::GeometryIntersectsClusterFinder finder;
- return capi_clusters(g, finder);
- });
- }
-
- Clusters*
- GEOSClusterEnvelopeIntersects_r(GEOSContextHandle_t extHandle, const Geometry* g)
- {
- return execute(extHandle, [&]() {
- geos::operation::cluster::EnvelopeIntersectsClusterFinder finder;
- return capi_clusters(g, finder);
- });
- }
-
- Clusters*
- GEOSClusterEnvelopeDistance_r(GEOSContextHandle_t extHandle, const Geometry* g, double d)
- {
- return execute(extHandle, [&]() {
- geos::operation::cluster::EnvelopeDistanceClusterFinder finder(d);
- return capi_clusters(g, finder);
- });
- }
-
- Clusters*
- GEOSClusterGeometryDistance_r(GEOSContextHandle_t extHandle, const Geometry* g, double d)
- {
- return execute(extHandle, [&]() {
- geos::operation::cluster::GeometryDistanceClusterFinder finder(d);
- return capi_clusters(g, finder);
- });
- }
-
- std::size_t GEOSClusterInfo_getNumClusters_r(GEOSContextHandle_t extHandle, const Clusters* clusters)
- {
- return execute(extHandle, 0, [&]() -> std::size_t {
- return static_cast(clusters->getNumClusters());
- });
- }
-
- std::size_t GEOSClusterInfo_getClusterSize_r(GEOSContextHandle_t extHandle, const Clusters* clusters, std::size_t i)
- {
- return execute(extHandle, 0, [&]() {
- return static_cast(clusters->getSize(i));
- });
- }
-
- const std::size_t* GEOSClusterInfo_getInputsForClusterN_r(GEOSContextHandle_t extHandle, const Clusters* clusters, std::size_t i)
- {
- return execute(extHandle, [&]() {
- return &*clusters->begin(i);
- });
- }
-
- std::size_t* GEOSClusterInfo_getClustersForInputs_r(GEOSContextHandle_t extHandle, const Clusters* clusters)
- {
- return execute(extHandle, [&]() {
- auto ids = clusters->getClusterIds(GEOS_CLUSTER_NONE);
- std::size_t* ids_buf = (size_t*) malloc(ids.size() * sizeof(std::size_t));
- std::copy(ids.begin(), ids.end(), ids_buf);
- return ids_buf;
- });
- }
-
- void GEOSClusterInfo_destroy_r(GEOSContextHandle_t, Clusters* clusters)
- {
- delete clusters;
- }
-
- Geometry*
- GEOSGeomFromWKT_r(GEOSContextHandle_t extHandle, const char* wkt)
- {
- return execute(extHandle, [&]() {
- GEOSContextHandleInternal_t* handle = reinterpret_cast(extHandle);
-
- const std::string wktstring(wkt);
- WKTReader r(static_cast(handle->geomFactory));
-
- auto g = r.read(wktstring);
- return g.release();
- });
- }
-
- char*
- GEOSGeomToWKT_r(GEOSContextHandle_t extHandle, const Geometry* g1)
- {
- return execute(extHandle, [&]() {
- // Deprecated, show untrimmed 2D output
- geos::io::WKTWriter writer;
- writer.setTrim(false);
- writer.setOutputDimension(2);
- char* result = gstrdup(writer.write(g1));
- return result;
- });
- }
-
- // Remember to free the result!
- unsigned char*
- GEOSGeomToWKB_buf_r(GEOSContextHandle_t extHandle, const Geometry* g, std::size_t* size)
- {
- using geos::io::WKBWriter;
-
- return execute(extHandle, [&]() {
- GEOSContextHandleInternal_t* handle = reinterpret_cast(extHandle);
-
- int byteOrder = handle->WKBByteOrder;
- WKBWriter w(handle->WKBOutputDims, byteOrder);
- std::ostringstream os(std::ios_base::binary);
- w.write(*g, os);
- std::string wkbstring(os.str());
- const std::size_t len = wkbstring.length();
-
- unsigned char* result = static_cast(malloc(len));
- if(result) {
- std::memcpy(result, wkbstring.c_str(), len);
- *size = len;
- }
- return result;
- });
- }
-
- Geometry*
- GEOSGeomFromWKB_buf_r(GEOSContextHandle_t extHandle, const unsigned char* wkb, std::size_t size)
- {
- using geos::io::WKBReader;
-
- return execute(extHandle, [&]() {
- GEOSContextHandleInternal_t* handle = reinterpret_cast(extHandle);
-
- WKBReader r(*(static_cast(handle->geomFactory)));
- return r.read(wkb, size).release();
- });
- }
-
- /* Read/write wkb hex values. Returned geometries are
- owned by the caller.*/
- unsigned char*
- GEOSGeomToHEX_buf_r(GEOSContextHandle_t extHandle, const Geometry* g, std::size_t* size)
- {
- using geos::io::WKBWriter;
-
- return execute(extHandle, [&]() {
- GEOSContextHandleInternal_t* handle = reinterpret_cast(extHandle);
-
- int byteOrder = handle->WKBByteOrder;
- WKBWriter w(handle->WKBOutputDims, byteOrder);
- std::ostringstream os(std::ios_base::binary);
- w.writeHEX(*g, os);
- std::string hexstring(os.str());
-
- char* result = gstrdup(hexstring);
- if(result) {
- *size = hexstring.length();
- }
-
- return reinterpret_cast(result);
- });
- }
-
- Geometry*
- GEOSGeomFromHEX_buf_r(GEOSContextHandle_t extHandle, const unsigned char* hex, std::size_t size)
- {
- using geos::io::WKBReader;
-
- return execute(extHandle, [&]() {
- GEOSContextHandleInternal_t* handle = reinterpret_cast(extHandle);
- std::string hexstring(reinterpret_cast(hex), size);
- WKBReader r(*(static_cast(handle->geomFactory)));
- std::istringstream is(std::ios_base::binary);
- is.str(hexstring);
- is.seekg(0, std::ios::beg); // rewind reader pointer
-
- auto g = r.readHEX(is);
- return g.release();
- });
- }
-
- char
- GEOSisEmpty_r(GEOSContextHandle_t extHandle, const Geometry* g1)
- {
- return execute(extHandle, 2, [&]() {
- return g1->isEmpty();
- });
- }
-
- char
- GEOSisSimple_r(GEOSContextHandle_t extHandle, const Geometry* g1)
- {
- return execute(extHandle, 2, [&]() {
- return g1->isSimple();
- });
- }
-
- char
- GEOSisSimpleDetail_r(GEOSContextHandle_t extHandle, const Geometry* g1, int returnAllPoints, Geometry** result)
- {
- return execute(extHandle, 2, [&]() {
- geos::operation::valid::IsSimpleOp iso(g1);
- iso.setFindAllLocations(returnAllPoints);
-
- *result = nullptr;
-
- bool simple = iso.isSimple();
- if (!simple) {
- auto locations = iso.getNonSimpleLocations();
- if (locations.size() == 1 || !returnAllPoints) {
- *result = extHandle->geomFactory->createPoint(locations.front()).release();
- } else {
- *result = extHandle->geomFactory->createMultiPoint(locations).release();
- }
- }
-
- return simple;
- });
- }
-
- char
- GEOSisRing_r(GEOSContextHandle_t extHandle, const Geometry* g)
- {
- return execute(extHandle, 2, [&]() {
- const Curve* ls = dynamic_cast(g);
- if(ls) {
- return ls->isRing();
- }
- else {
- return false;
- }
- });
- }
-
- //free the result of this
- char*
- GEOSGeomType_r(GEOSContextHandle_t extHandle, const Geometry* g1)
- {
- return execute(extHandle, [&]() {
- std::string s = g1->getGeometryType();
-
- char* result = gstrdup(s);
- return result;
- });
- }
-
- // Return postgis geometry type index
- int
- GEOSGeomTypeId_r(GEOSContextHandle_t extHandle, const Geometry* g1)
- {
- return execute(extHandle, -1, [&]() {
- return static_cast(g1->getGeometryTypeId());
- });
- }
-
-//-------------------------------------------------------------------
-// GEOS functions that return geometries
-//-------------------------------------------------------------------
-
- Geometry*
- GEOSEnvelope_r(GEOSContextHandle_t extHandle, const Geometry* g1)
- {
- return execute(extHandle, [&]() {
- Geometry* g3 = g1->getEnvelope().release();
- g3->setSRID(g1->getSRID());
- return g3;
- });
- }
-
- Geometry*
- GEOSIntersection_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
- {
- return execute(extHandle, [&]() {
- auto g3 = g1->intersection(g2);
- g3->setSRID(g1->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSIntersectionPrec_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double gridSize)
- {
- return execute(extHandle, [&]() {
- std::unique_ptr pm;
- if(gridSize != 0) {
- pm.reset(new PrecisionModel(1.0 / gridSize));
- }
- else {
- pm.reset(new PrecisionModel());
- }
- auto g3 = gridSize != 0 ?
- OverlayNG::overlay(g1, g2, OverlayNG::INTERSECTION, pm.get())
- :
- OverlayNGRobust::Overlay(g1, g2, OverlayNG::INTERSECTION);
- g3->setSRID(g1->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSBuffer_r(GEOSContextHandle_t extHandle, const Geometry* g1, double width, int quadrantsegments)
- {
- return execute(extHandle, [&]() {
- auto g3 = g1->buffer(width, quadrantsegments);
- g3->setSRID(g1->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSBufferWithStyle_r(GEOSContextHandle_t extHandle, const Geometry* g1, double width, int quadsegs, int endCapStyle,
- int joinStyle, double mitreLimit)
- {
- using geos::operation::buffer::BufferParameters;
- using geos::operation::buffer::BufferOp;
- using geos::util::IllegalArgumentException;
-
- return execute(extHandle, [&]() {
- BufferParameters bp;
- bp.setQuadrantSegments(quadsegs);
-
- if(endCapStyle > BufferParameters::CAP_SQUARE) {
- throw IllegalArgumentException("Invalid buffer endCap style");
- }
- bp.setEndCapStyle(
- static_cast(endCapStyle)
- );
-
- if(joinStyle > BufferParameters::JOIN_BEVEL) {
- throw IllegalArgumentException("Invalid buffer join style");
- }
- bp.setJoinStyle(
- static_cast(joinStyle)
- );
- bp.setMitreLimit(mitreLimit);
- BufferOp op(g1, bp);
- std::unique_ptr g3 = op.getResultGeometry(width);
- g3->setSRID(g1->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSDensify_r(GEOSContextHandle_t extHandle, const Geometry* g, double tolerance)
- {
- using geos::geom::util::Densifier;
-
- return execute(extHandle, [&]() {
- Densifier densifier(g);
- densifier.setDistanceTolerance(tolerance);
- auto g3 = densifier.getResultGeometry();
- g3->setSRID(g->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSOffsetCurve_r(GEOSContextHandle_t extHandle, const Geometry* g1, double width, int quadsegs, int joinStyle,
- double mitreLimit)
- {
- return execute(extHandle, [&]() {
- BufferParameters bp;
- //-- use default cap style ROUND
- bp.setQuadrantSegments(quadsegs);
-
- if(joinStyle > BufferParameters::JOIN_BEVEL) {
- throw IllegalArgumentException("Invalid buffer join style");
- }
- bp.setJoinStyle(
- static_cast(joinStyle)
- );
- bp.setMitreLimit(mitreLimit);
-
- OffsetCurve oc(*g1, width, bp);
- std::unique_ptr g3 = oc.getCurve();
- g3->setSRID(g1->getSRID());
- return g3.release();
- });
- }
-
- /* @deprecated in 3.3.0 */
- Geometry*
- GEOSSingleSidedBuffer_r(GEOSContextHandle_t extHandle, const Geometry* g1, double width, int quadsegs, int joinStyle,
- double mitreLimit, int leftSide)
- {
- return execute(extHandle, [&]() {
- BufferParameters bp;
- bp.setEndCapStyle(BufferParameters::CAP_FLAT);
- bp.setQuadrantSegments(quadsegs);
-
- if(joinStyle > BufferParameters::JOIN_BEVEL) {
- throw IllegalArgumentException("Invalid buffer join style");
- }
- bp.setJoinStyle(
- static_cast(joinStyle)
- );
- bp.setMitreLimit(mitreLimit);
-
- bool isLeftSide = leftSide == 0 ? false : true;
- BufferBuilder bufBuilder(bp);
- std::unique_ptr g3 = bufBuilder.bufferLineSingleSided(g1, width, isLeftSide);
- g3->setSRID(g1->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSConvexHull_r(GEOSContextHandle_t extHandle, const Geometry* g1)
- {
- return execute(extHandle, [&]() {
- auto g3 = g1->convexHull();
- g3->setSRID(g1->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSConcaveHull_r(GEOSContextHandle_t extHandle,
- const Geometry* g1,
- double ratio,
- unsigned int allowHoles)
- {
- return execute(extHandle, [&]() {
- ConcaveHull hull(g1);
- hull.setMaximumEdgeLengthRatio(ratio);
- hull.setHolesAllowed(allowHoles);
- std::unique_ptr g3 = hull.getHull();
- g3->setSRID(g1->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSConcaveHullByLength_r(GEOSContextHandle_t extHandle,
- const Geometry* g1,
- double length,
- unsigned int allowHoles)
- {
- return execute(extHandle, [&]() {
- ConcaveHull hull(g1);
- hull.setMaximumEdgeLength(length);
- hull.setHolesAllowed(allowHoles);
- std::unique_ptr g3 = hull.getHull();
- g3->setSRID(g1->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSPolygonHullSimplify_r(GEOSContextHandle_t extHandle,
- const Geometry* g1,
- unsigned int isOuter,
- double vertexNumFraction)
- {
- return execute(extHandle, [&]() {
- std::unique_ptr g3 = PolygonHullSimplifier::hull(g1, isOuter, vertexNumFraction);
- g3->setSRID(g1->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSPolygonHullSimplifyMode_r(GEOSContextHandle_t extHandle,
- const Geometry* g1,
- unsigned int isOuter,
- unsigned int parameterMode,
- double parameter)
- {
- return execute(extHandle, [&]() {
- if (parameterMode == GEOSHULL_PARAM_AREA_RATIO) {
- std::unique_ptr g3 = PolygonHullSimplifier::hullByAreaDelta(g1, isOuter, parameter);
- g3->setSRID(g1->getSRID());
- return g3.release();
- }
- else if (parameterMode == GEOSHULL_PARAM_VERTEX_RATIO) {
- std::unique_ptr g3 = PolygonHullSimplifier::hull(g1, isOuter, parameter);
- g3->setSRID(g1->getSRID());
- return g3.release();
- }
- else {
- throw IllegalArgumentException("GEOSPolygonHullSimplifyMode_r: Unknown parameterMode");
- }
- });
- }
-
- Geometry*
- GEOSConcaveHullOfPolygons_r(GEOSContextHandle_t extHandle,
- const Geometry* g1,
- double lengthRatio,
- unsigned int isTight,
- unsigned int isHolesAllowed)
- {
- return execute(extHandle, [&]() {
- std::unique_ptr g3 =
- ConcaveHullOfPolygons::concaveHullByLengthRatio(
- g1, lengthRatio,
- isTight > 0,
- isHolesAllowed > 0);
- g3->setSRID(g1->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSMinimumRotatedRectangle_r(GEOSContextHandle_t extHandle, const Geometry* g)
- {
- using geos::algorithm::MinimumAreaRectangle;
-
- return execute(extHandle, [&]() {
- auto g3 = MinimumAreaRectangle::getMinimumRectangle(g);
- g3->setSRID(g->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSMaximumInscribedCircle_r(GEOSContextHandle_t extHandle, const Geometry* g, double tolerance)
- {
- return execute(extHandle, [&]() {
- geos::algorithm::construct::MaximumInscribedCircle mic(g, tolerance);
- auto g3 = mic.getRadiusLine();
- g3->setSRID(g->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSLargestEmptyCircle_r(GEOSContextHandle_t extHandle, const Geometry* g, const GEOSGeometry* boundary, double tolerance)
- {
- return execute(extHandle, [&]() {
- geos::algorithm::construct::LargestEmptyCircle lec(g, boundary, tolerance);
- auto g3 = lec.getRadiusLine();
- g3->setSRID(g->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSMinimumWidth_r(GEOSContextHandle_t extHandle, const Geometry* g)
- {
- return execute(extHandle, [&]() {
- geos::algorithm::MinimumDiameter m(g);
- auto g3 = m.getDiameter();
- g3->setSRID(g->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSMinimumClearanceLine_r(GEOSContextHandle_t extHandle, const Geometry* g)
- {
- return execute(extHandle, [&]() {
- geos::precision::MinimumClearance mc(g);
- auto g3 = mc.getLine();
- g3->setSRID(g->getSRID());
- return g3.release();
- });
- }
-
- int
- GEOSMinimumClearance_r(GEOSContextHandle_t extHandle, const Geometry* g, double* d)
- {
- return execute(extHandle, 2, [&]() {
- geos::precision::MinimumClearance mc(g);
- double res = mc.getDistance();
- *d = res;
- return 0;
- });
- }
-
-
- Geometry*
- GEOSDifference_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
- {
- return execute(extHandle, [&]() {
- auto g3 = g1->difference(g2);
- g3->setSRID(g1->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSDifferencePrec_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double gridSize)
- {
- return execute(extHandle, [&]() {
-
- std::unique_ptr pm;
- if(gridSize != 0) {
- pm.reset(new PrecisionModel(1.0 / gridSize));
- }
- else {
- pm.reset(new PrecisionModel());
- }
- auto g3 = gridSize != 0 ?
- OverlayNG::overlay(g1, g2, OverlayNG::DIFFERENCE, pm.get())
- :
- OverlayNGRobust::Overlay(g1, g2, OverlayNG::DIFFERENCE);
- g3->setSRID(g1->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSBoundary_r(GEOSContextHandle_t extHandle, const Geometry* g1)
- {
- return execute(extHandle, [&]() {
- auto g3 = g1->getBoundary();
- g3->setSRID(g1->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSSymDifference_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
- {
- return execute(extHandle, [&]() {
- auto g3 = g1->symDifference(g2);
- g3->setSRID(g1->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSSymDifferencePrec_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double gridSize)
- {
- return execute(extHandle, [&]() {
-
- std::unique_ptr pm;
- if(gridSize != 0) {
- pm.reset(new PrecisionModel(1.0 / gridSize));
- }
- else {
- pm.reset(new PrecisionModel());
- }
- auto g3 = gridSize != 0 ?
- OverlayNG::overlay(g1, g2, OverlayNG::SYMDIFFERENCE, pm.get())
- :
- OverlayNGRobust::Overlay(g1, g2, OverlayNG::SYMDIFFERENCE);
- g3->setSRID(g1->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSUnion_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
- {
- return execute(extHandle, [&]() {
- auto g3 = g1->Union(g2);
- g3->setSRID(g1->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSUnionPrec_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double gridSize)
- {
- return execute(extHandle, [&]() {
-
- std::unique_ptr pm;
- if(gridSize != 0) {
- pm.reset(new PrecisionModel(1.0 / gridSize));
- }
- else {
- pm.reset(new PrecisionModel());
- }
- auto g3 = gridSize != 0 ?
- OverlayNG::overlay(g1, g2, OverlayNG::UNION, pm.get())
- :
- OverlayNGRobust::Overlay(g1, g2, OverlayNG::UNION);
- g3->setSRID(g1->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSCoverageUnion_r(GEOSContextHandle_t extHandle, const Geometry* g)
- {
- return execute(extHandle, [&]() {
- auto g3 = geos::coverage::CoverageUnion::Union(g);
- g3->setSRID(g->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSDisjointSubsetUnion_r(GEOSContextHandle_t extHandle, const Geometry* g)
- {
- return execute(extHandle, [&]() {
- auto g3 = geos::operation::geounion::DisjointSubsetUnion::Union(g);
- g3->setSRID(g->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSUnaryUnion_r(GEOSContextHandle_t extHandle, const Geometry* g)
- {
- return execute(extHandle, [&]() {
- std::unique_ptr g3(g->Union());
- g3->setSRID(g->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSUnaryUnionPrec_r(GEOSContextHandle_t extHandle, const Geometry* g1, double gridSize)
- {
- return execute(extHandle, [&]() {
-
- std::unique_ptr pm;
- if(gridSize != 0) {
- pm.reset(new PrecisionModel(1.0 / gridSize));
- }
- else {
- pm.reset(new PrecisionModel());
- }
- auto g3 = gridSize != 0 ?
- UnaryUnionNG::Union(g1, *pm)
- :
- OverlayNGRobust::Union(g1);
- g3->setSRID(g1->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSNode_r(GEOSContextHandle_t extHandle, const Geometry* g)
- {
- return execute(extHandle, [&]() {
- auto g3 = geos::noding::GeometryNoder::node(*g);
- g3->setSRID(g->getSRID());
- return g3.release();
- });
- }
-
- Geometry*
- GEOSUnionCascaded_r(GEOSContextHandle_t extHandle, const Geometry* g1)
- {
- return execute(extHandle, [&]() {
- // CascadedUnion is the same as UnaryUnion, except that
- // CascadedUnion only works on MultiPolygon, so we just delegate
- // now and retain a check on MultiPolygon type.
- const MultiPolygon *p = dynamic_cast(g1);
- if (!p) {
- throw IllegalArgumentException("Invalid argument (must be a MultiPolygon)");
- }
- return GEOSUnaryUnion_r(extHandle, g1);
- });
- }
-
- Geometry*
- GEOSPointOnSurface_r(GEOSContextHandle_t extHandle, const Geometry* g1)
- {
- return execute(extHandle, [&]() {
- auto ret = g1->getInteriorPoint();
- ret->setSRID(g1->getSRID());
- return ret.release();
- });
- }
-
- Geometry*
- GEOSClipByRect_r(GEOSContextHandle_t extHandle, const Geometry* g, double xmin, double ymin, double xmax, double ymax)
- {
- return execute(extHandle, [&]() {
- using geos::operation::intersection::Rectangle;
- using geos::operation::intersection::RectangleIntersection;
- Rectangle rect(xmin, ymin, xmax, ymax);
- std::unique_ptr g3 = RectangleIntersection::clip(*g, rect);
- g3->setSRID(g->getSRID());
- return g3.release();
- });
- }
-
- int
- GEOSGridIntersectionFractions_r(GEOSContextHandle_t extHandle, const Geometry* g, double xmin, double ymin,
- double xmax, double ymax, unsigned nx, unsigned ny, float* buf)
- {
- return execute(extHandle, 0, [&]() {
- Envelope env(xmin, xmax, ymin, ymax);
- double dx = env.getWidth() / static_cast(nx);
- double dy = env.getHeight() / static_cast(ny);
- geos::operation::grid::Grid grid(env, dx, dy);
-
- // Matrix wants a shared_ptr, but we don't actually want anything to be freed because
- // buf is externally owned. So we give it an empty deleter.
- std::shared_ptr bufPtr(buf, [](float*) {});
-
- auto cov = std::make_shared>(ny, nx, bufPtr);
- geos::operation::grid::GridIntersection isect(grid, *g, cov);
-
- return 1;
- });
- }
-
- Geometry*
- GEOSGeom_transformXY_r(GEOSContextHandle_t handle, const GEOSGeometry* g, GEOSTransformXYCallback callback, void* userdata) {
-
- struct TransformFilter final: public geos::geom::CoordinateFilter {
- TransformFilter(GEOSTransformXYCallback p_callback,
- void* p_userdata) :
- m_callback(p_callback),
- m_userdata(p_userdata) {}
-
- void filter_rw(CoordinateXY* c) const override {
- if (!m_callback(&(c->x), &(c->y), m_userdata)) {
- throw std::runtime_error(std::string("Failed to transform coordinates."));
- }
- }
-
- GEOSTransformXYCallback m_callback;
- void* m_userdata;
- };
-
- return execute(handle, [&]() {
- TransformFilter filter(callback, userdata);
- auto ret = g->clone();
- ret->apply_rw(&filter);
- ret->geometryChanged();
- return ret.release();
- });
- }
-
-
- Geometry*
- GEOSGeom_transformXYZ_r(GEOSContextHandle_t handle, const GEOSGeometry* g, GEOSTransformXYZCallback callback, void* userdata) {
-
- struct TransformFilter final: public geos::geom::CoordinateFilter {
- TransformFilter(GEOSTransformXYZCallback p_callback,
- void* p_userdata) :
- m_callback(p_callback),
- m_userdata(p_userdata) {}
-
- void filter_rw(Coordinate* c) const override {
- if (!m_callback(&(c->x), &(c->y), &(c->z), m_userdata)) {
- throw std::runtime_error(std::string("Failed to transform coordinates."));
- }
- }
-
- GEOSTransformXYZCallback m_callback;
- void* m_userdata;
- };
-
- return execute(handle, [&]() {
- TransformFilter filter(callback, userdata);
- auto ret = g->clone();
- ret->apply_rw(&filter);
- ret->geometryChanged();
- return ret.release();
- });
- }
-
-
-//-------------------------------------------------------------------
-// memory management functions
-//------------------------------------------------------------------
-
- void
- GEOSGeom_destroy_r(GEOSContextHandle_t extHandle, Geometry* a)
- {
- execute(extHandle, [&]() {
- // FIXME: mloskot: Does this try-catch around delete means that
- // destructors in GEOS may throw? If it does, this is a serious
- // violation of "never throw an exception from a destructor" principle
- delete a;
- });
- }
-
- void
- GEOSGeom_setUserData_r(GEOSContextHandle_t extHandle, Geometry* g, void* userData)
- {
- execute(extHandle, [&]() {
- g->setUserData(userData);
- });
- }
-
- void
- GEOSSetSRID_r(GEOSContextHandle_t extHandle, Geometry* g, int srid)
- {
- execute(extHandle, [&]() {
- g->setSRID(srid);
- });
- }
-
-
- int
- GEOSGetNumCoordinates_r(GEOSContextHandle_t extHandle, const Geometry* g)
- {
- return execute(extHandle, -1, [&]() {
- return static_cast(g->getNumPoints());
- });
- }
-
- /*
- * Return -1 on exception, 0 otherwise.
- * Converts Geometry to normal form (or canonical form).
- */
- int
- GEOSNormalize_r(GEOSContextHandle_t extHandle, Geometry* g)
- {
- return execute(extHandle, -1, [&]() {
- g->normalize();
- return 0; // SUCCESS
- });
- }
-
- int
- GEOSOrientPolygons_r(GEOSContextHandle_t extHandle, Geometry* g, int exteriorCW)
- {
- return execute(extHandle, -1, [&]() {
- class OrientPolygons : public geos::geom::GeometryComponentFilter {
- public:
- OrientPolygons(bool isExteriorCW) : exteriorCW(isExteriorCW) {}
-
- void filter_rw(Geometry* g) override {
- if (g->getGeometryTypeId() == geos::geom::GeometryTypeId::GEOS_POLYGON) {
- auto p = geos::detail::down_cast(g);
- p->orientRings(exteriorCW);
- } else if (g->getGeometryTypeId() == geos::geom::GeometryTypeId::GEOS_CURVEPOLYGON) {
- throw geos::util::UnsupportedOperationException("Curved geometries not supported.");
- }
- }
-
- private:
- bool exteriorCW;
- };
-
- OrientPolygons op(exteriorCW);
- g->apply_rw(&op);
-
- return 0;
- });
- }
-
- int
- GEOSGetNumInteriorRings_r(GEOSContextHandle_t extHandle, const Geometry* g1)
- {
- return execute(extHandle, -1, [&]() {
- const Surface* p = dynamic_cast(g1);
- if(!p) {
- throw IllegalArgumentException("Argument is not a Surface");
- }
- return static_cast(p->getNumInteriorRing());
- });
- }
-
-
- // returns -1 on error and 1 for non-multi geometries
- int
- GEOSGetNumGeometries_r(GEOSContextHandle_t extHandle, const Geometry* g1)
- {
- return execute(extHandle, -1, [&]() {
- return static_cast(g1->getNumGeometries());
- });
- }
-
-
- /*
- * Call only on GEOMETRYCOLLECTION or MULTI*.
- * Return a pointer to the internal Geometry.
- */
- const Geometry*
- GEOSGetGeometryN_r(GEOSContextHandle_t extHandle, const Geometry* g1, int n)
- {
- return execute(extHandle, [&]() {
- if(n < 0) {
- throw IllegalArgumentException("Index must be non-negative.");
- }
- return g1->getGeometryN(static_cast(n));
- });
- }
-
- /*
- * Call only on LINESTRING
- * Returns NULL on exception
- */
- Geometry*
- GEOSGeomGetPointN_r(GEOSContextHandle_t extHandle, const Geometry* g1, int n)
- {
- return execute(extHandle, [&]() {
- const SimpleCurve* ls = dynamic_cast(g1);
- if(!ls) {
- throw IllegalArgumentException("Argument is not a SimpleCurve");
- }
- if(n < 0) {
- throw IllegalArgumentException("Index must be non-negative.");
- }
- return ls->getPointN(static_cast(n)).release();
- });
- }
-
- /*
- * Call only on LINESTRING
- */
- Geometry*
- GEOSGeomGetStartPoint_r(GEOSContextHandle_t extHandle, const Geometry* g1)
- {
- return execute(extHandle, [&]() {
- const SimpleCurve* ls = dynamic_cast(g1);
- if(!ls) {
- throw IllegalArgumentException("Argument is not a SimpleCurve");
- }
-
- return ls->getStartPoint().release();
- });
- }
-
- /*
- * Call only on LINESTRING
- */
- Geometry*
- GEOSGeomGetEndPoint_r(GEOSContextHandle_t extHandle, const Geometry* g1)
- {
- return execute(extHandle, [&]() {
- const SimpleCurve* ls = dynamic_cast(g1);
- if(!ls) {
- throw IllegalArgumentException("Argument is not a SimpleCurve");
- }
- return ls->getEndPoint().release();
- });
- }
-
- /*
- * Call only on LINESTRING or MULTILINESTRING
- * return 2 on exception, 1 on true, 0 on false
- */
- char
- GEOSisClosed_r(GEOSContextHandle_t extHandle, const Geometry* g1)
- {
- return execute(extHandle, 2, [&]() {
- const Curve* ls = dynamic_cast(g1);
- if(ls) {
- return ls->isClosed();
- }
-
- const MultiLineString* mls = dynamic_cast(g1);
- if(mls) {
- return mls->isClosed();
- }
-
- const MultiCurve* mc = dynamic_cast(g1);
- if(mc) {
- return mc->isClosed();
- }
-
- throw IllegalArgumentException("Argument is not a Curve, MultiLineString, or MultiCurve");
- });
- }
-
- /*
- * Call only on LINESTRING
- * return 0 on exception, otherwise 1
- */
- int
- GEOSGeomGetLength_r(GEOSContextHandle_t extHandle, const Geometry* g1, double* length)
- {
- return execute(extHandle, 0, [&]() {
- const LineString* ls = dynamic_cast(g1);
- if(!ls) {
- throw IllegalArgumentException("Argument is not a LineString");
- }
- *length = ls->getLength();
- return 1;
- });
- }
-
- /*
- * Call only on LINESTRING
- */
- int
- GEOSGeomGetNumPoints_r(GEOSContextHandle_t extHandle, const Geometry* g1)
- {
- return execute(extHandle, -1, [&]() {
- const SimpleCurve* ls = dynamic_cast(g1);
- if(!ls) {
- throw IllegalArgumentException("Argument is not a SimpleCurve");
- }
- return static_cast(ls->getNumPoints());
- });
- }
-
- /*
- * For POINT
- * returns 0 on exception, otherwise 1
- */
- int
- GEOSGeomGetX_r(GEOSContextHandle_t extHandle, const Geometry* g1, double* x)
- {
- return execute(extHandle, 0, [&]() {
- const Point* po = dynamic_cast(g1);
- if(!po) {
- throw IllegalArgumentException("Argument is not a Point");
- }
- *x = po->getX();
- return 1;
- });
- }
-
- /*
- * For POINT
- * returns 0 on exception, otherwise 1
- */
- int
- GEOSGeomGetY_r(GEOSContextHandle_t extHandle, const Geometry* g1, double* y)
- {
- return execute(extHandle, 0, [&]() {
- const Point* po = dynamic_cast(g1);
- if(!po) {
- throw IllegalArgumentException("Argument is not a Point");
- }
- *y = po->getY();
- return 1;
- });
- }
-
- /*
- * For POINT
- * returns 0 on exception, otherwise 1
- */
- int
- GEOSGeomGetZ_r(GEOSContextHandle_t extHandle, const Geometry* g1, double* z)
- {
- return execute(extHandle, 0, [&]() {
- const Point* po = dynamic_cast(g1);
- if(!po) {
- throw IllegalArgumentException("Argument is not a Point");
- }
- *z = po->getZ();
- return 1;
- });
- }
-
- /*
- * For POINT
- * returns 0 on exception, otherwise 1
- */
- int
- GEOSGeomGetM_r(GEOSContextHandle_t extHandle, const Geometry* g1, double* m)
- {
- return execute(extHandle, 0, [&]() {
- const Point* po = dynamic_cast(g1);
- if(!po) {
- throw IllegalArgumentException("Argument is not a Point");
- }
- *m = po->getM();
- return 1;
- });
- }
-
- /*
- * Call only on polygon
- * Return a pointer to the internal Geometry.
- */
- const Geometry*
- GEOSGetExteriorRing_r(GEOSContextHandle_t extHandle, const Geometry* g1)
- {
- return execute(extHandle, [&]() {
- const Surface* p = dynamic_cast(g1);
- if(!p) {
- throw IllegalArgumentException("Invalid argument (must be a Surface)");
- }
- return p->getExteriorRing();
- });
- }
-
- /*
- * Call only on polygon
- * Return a pointer to internal storage, do not destroy it.
- */
- const Geometry*
- GEOSGetInteriorRingN_r(GEOSContextHandle_t extHandle, const Geometry* g1, int n)
- {
- return execute(extHandle, [&]() {
- const Surface* p = dynamic_cast(g1);
- if(!p) {
- throw IllegalArgumentException("Invalid argument (must be a Surface)");
- }
- if(n < 0) {
- throw IllegalArgumentException("Index must be non-negative.");
- }
- return p->getInteriorRingN(static_cast(n));
- });
- }
-
- Geometry*
- GEOSGetCentroid_r(GEOSContextHandle_t extHandle, const Geometry* g)
- {
- return execute(extHandle, [&]() -> Geometry* {
- auto ret = g->getCentroid();
- ret->setSRID(g->getSRID());
- return ret.release();
- });
- }
-
- int
- GEOSHilbertCode_r(GEOSContextHandle_t extHandle, const GEOSGeometry *geom,
- const GEOSGeometry* extent, unsigned int level,
- unsigned int *code)
- {
- using geos::shape::fractal::HilbertEncoder;
-
- return execute(extHandle, 0, [&]() {
- Envelope e = *extent->getEnvelopeInternal();
- HilbertEncoder encoder(level, e);
- *code = encoder.encode(geom->getEnvelopeInternal());
- return 1;
- });
- }
-
- Geometry*
- GEOSMinimumBoundingCircle_r(GEOSContextHandle_t extHandle, const Geometry* g,
- double* radius, Geometry** center)
- {
- return execute(extHandle, [&]() -> Geometry* {
- GEOSContextHandleInternal_t* handle = reinterpret_cast(extHandle);
-
- geos::algorithm::MinimumBoundingCircle mc(g);
- std::unique_ptr ret = mc.getCircle();
- const GeometryFactory* gf = handle->geomFactory;
- if (center) *center = gf->createPoint(mc.getCentre()).release();
- if (radius) *radius = mc.getRadius();
- ret->setSRID(g->getSRID());
- return ret.release();
- });
- }
-
- Geometry*
- GEOSGeom_createEmptyCollection_r(GEOSContextHandle_t extHandle, int type)
- {
- return execute(extHandle, [&]() {
- GEOSContextHandleInternal_t* handle = reinterpret_cast(extHandle);
- const GeometryFactory* gf = handle->geomFactory;
-
- std::unique_ptr g = 0;
- switch(type) {
- case GEOS_GEOMETRYCOLLECTION:
- g = gf->createGeometryCollection();
- break;
- case GEOS_MULTIPOINT:
- g = gf->createMultiPoint();
- break;
- case GEOS_MULTILINESTRING:
- g = gf->createMultiLineString();
- break;
- case GEOS_MULTIPOLYGON:
- g = gf->createMultiPolygon();
- break;
- case GEOS_MULTICURVE:
- g = gf->createMultiCurve();
- break;
- case GEOS_MULTISURFACE:
- g = gf->createMultiSurface();
- break;
- default:
- throw IllegalArgumentException("Unsupported type request for GEOSGeom_createEmptyCollection_r");
- }
-
- return g.release();
- });
- }
-
- Geometry*
- GEOSGeom_createCollection_r(GEOSContextHandle_t extHandle, int type, Geometry** geoms, unsigned int ngeoms)
- {
- return execute(extHandle, [&]() {
- GEOSContextHandleInternal_t* handle = reinterpret_cast(extHandle);
-
- const GeometryFactory* gf = handle->geomFactory;
-
- std::vector> vgeoms(ngeoms);
- for (std::size_t i = 0; i < ngeoms; i++) {
- vgeoms[i].reset(geoms[i]);
- }
-
- std::unique_ptr g;
- switch(type) {
- case GEOS_GEOMETRYCOLLECTION:
- g = gf->createGeometryCollection(std::move(vgeoms));
- break;
- case GEOS_MULTIPOINT:
- g = gf->createMultiPoint(std::move(vgeoms));
- break;
- case GEOS_MULTILINESTRING:
- g = gf->createMultiLineString(std::move(vgeoms));
- break;
- case GEOS_MULTIPOLYGON:
- g = gf->createMultiPolygon(std::move(vgeoms));
- break;
- case GEOS_MULTICURVE:
- g = gf->createMultiCurve(std::move(vgeoms));
- break;
- case GEOS_MULTISURFACE:
- g = gf->createMultiSurface(std::move(vgeoms));
- break;
- default:
- handle->ERROR_MESSAGE("Unsupported type request for GEOSGeom_createCollection_r");
- }
-
- return g.release();
- });
- }
-
- Geometry**
- GEOSGeom_releaseCollection_r(GEOSContextHandle_t extHandle, Geometry* collection, unsigned int * ngeoms)
- {
- return execute(extHandle, [&]() {
- GEOSContextHandleInternal_t* handle = reinterpret_cast(extHandle);
-
- if (ngeoms == nullptr) {
- handle->ERROR_MESSAGE("Parameter ngeoms of GEOSGeom_releaseCollection_r must not be null");
- }
-
- GeometryCollection *col = dynamic_cast(collection);
- if (!col) {
- handle->ERROR_MESSAGE("Parameter collection of GEOSGeom_releaseCollection_r must not be a collection");
- } else {
- *ngeoms = static_cast(col->getNumGeometries());
- }
-
- // Early exit on empty/null input
- if (!col || *ngeoms == 0) {
- return static_cast(nullptr);
- }
-
- std::vector> subgeoms = col->releaseGeometries();
-
- Geometry** subgeomArray = static_cast(malloc(sizeof(Geometry*) * subgeoms.size()));
- for (std::size_t i = 0; i < subgeoms.size(); i++) {
- subgeomArray[i] = subgeoms[i].release();
- }
-
- return subgeomArray;
- });
- }
-
- Geometry*
- GEOSPolygonize_r(GEOSContextHandle_t extHandle, const Geometry* const* g, unsigned int ngeoms)
- {
- using geos::operation::polygonize::Polygonizer;
-
- return execute(extHandle, [&]() {
- GEOSContextHandleInternal_t* handle = reinterpret_cast(extHandle);
-
- // Polygonize
- Polygonizer plgnzr;
- for(std::size_t i = 0; i < ngeoms; ++i) {
- plgnzr.add(g[i]);
- }
-
- auto polys = plgnzr.getPolygons();
- const GeometryFactory* gf = handle->geomFactory;
- return gf->createGeometryCollection(std::move(polys)).release();
- });
- }
-
- Geometry*
- GEOSPolygonize_valid_r(GEOSContextHandle_t extHandle, const Geometry* const* g, unsigned int ngeoms)
- {
- using geos::operation::polygonize::Polygonizer;
-
- return execute(extHandle, [&]() -> Geometry* {
- GEOSContextHandleInternal_t* handle = reinterpret_cast(extHandle);
- Geometry* out;
-
- // Polygonize
- Polygonizer plgnzr(true);
- int srid = 0;
- for(std::size_t i = 0; i < ngeoms; ++i) {
- plgnzr.add(g[i]);
- srid = g[i]->getSRID();
- }
-
- auto polys = plgnzr.getPolygons();
- if (polys.empty()) {
- out = handle->geomFactory->createGeometryCollection().release();
- } else if (polys.size() == 1) {
- return polys[0].release();
- } else {
- return handle->geomFactory->createMultiPolygon(std::move(polys)).release();
- }
-
- out->setSRID(srid);
- return out;
- });
- }
-
- Geometry*
- GEOSBuildArea_r(GEOSContextHandle_t extHandle, const Geometry* g)
- {
- using geos::operation::polygonize::BuildArea;
-
- return execute(extHandle, [&]() {
- BuildArea builder;
- auto out = builder.build(g);
- out->setSRID(g->getSRID());
- return out.release();
- });
- }
-
-/************************************************************************
- * Make Valid
- */
-
- Geometry*
- GEOSMakeValid_r(GEOSContextHandle_t extHandle, const Geometry* g)
- {
- GEOSMakeValidParams params;
- params.method = GEOS_MAKE_VALID_LINEWORK;
- params.keepCollapsed = 1;
- return GEOSMakeValidWithParams_r(extHandle, g, ¶ms);
- }
-
- GEOSMakeValidParams*
- GEOSMakeValidParams_create_r(GEOSContextHandle_t extHandle)
- {
- return execute(extHandle, [&]() {
- GEOSMakeValidParams* p = new GEOSMakeValidParams();
- p->method = GEOS_MAKE_VALID_LINEWORK;
- p->keepCollapsed = 0;
- return p;
- });
- }
-
- void
- GEOSMakeValidParams_destroy_r(GEOSContextHandle_t extHandle, GEOSMakeValidParams* parms)
- {
- (void)extHandle;
- delete parms;
- }
-
- int
- GEOSMakeValidParams_setKeepCollapsed_r(GEOSContextHandle_t extHandle,
- GEOSMakeValidParams* p, int keepCollapsed)
- {
- return execute(extHandle, 0, [&]() {
- p->keepCollapsed = keepCollapsed;
- return 1;
- });
- }
-
- int
- GEOSMakeValidParams_setMethod_r(GEOSContextHandle_t extHandle,
- GEOSMakeValidParams* p, GEOSMakeValidMethods method)
- {
- return execute(extHandle, 0, [&]() {
- p->method = method;
- return 1;
- });
- }
-
- Geometry*
- GEOSMakeValidWithParams_r(
- GEOSContextHandle_t extHandle,
- const Geometry* g,
- const GEOSMakeValidParams* params)
- {
- using geos::geom::util::GeometryFixer;
- using geos::operation::valid::MakeValid;
-
- if (params && params->method == GEOS_MAKE_VALID_LINEWORK) {
- return execute(extHandle, [&]() {
- MakeValid makeValid;
- auto out = makeValid.build(g);
- out->setSRID(g->getSRID());
- return out.release();
- });
- }
- else if (params && params->method == GEOS_MAKE_VALID_STRUCTURE) {
- return execute(extHandle, [&]() {
- GeometryFixer fixer(g);
- fixer.setKeepCollapsed(params->keepCollapsed == 0 ? false : true);
- auto out = fixer.getResult();
- out->setSRID(g->getSRID());
- return out.release();
- });
- }
- else {
- extHandle->ERROR_MESSAGE("Unknown method in GEOSMakeValidParams");
- return nullptr;
- }
- }
-
- Geometry*
- GEOSRemoveRepeatedPoints_r(
- GEOSContextHandle_t extHandle,
- const Geometry* g,
- double tolerance)
- {
- using geos::operation::valid::RepeatedPointRemover;
-
- return execute(extHandle, [&]() {
- auto out = RepeatedPointRemover::removeRepeatedPoints(g, tolerance);
- out->setSRID(g->getSRID());
- return out.release();
- });
- }
-
- Geometry*
- GEOSPolygonizer_getCutEdges_r(GEOSContextHandle_t extHandle, const Geometry* const* g, unsigned int ngeoms)
- {
- using geos::operation::polygonize::Polygonizer;
-
- return execute(extHandle, [&]() {
- GEOSContextHandleInternal_t* handle = reinterpret_cast(extHandle);
- const GeometryFactory* gf = handle->geomFactory;
-
- // Polygonize
- Polygonizer plgnzr;
- int srid = 0;
- for(std::size_t i = 0; i < ngeoms; ++i) {
- plgnzr.add(g[i]);
- srid = g[i]->getSRID();
- }
-
- const std::vector& lines = plgnzr.getCutEdges();
-
- // We need a vector of Geometry pointers, not Polygon pointers.
- // STL vector doesn't allow transparent upcast of this
- // nature, so we explicitly convert.
- // (it's just a waste of processor and memory, btw)
- // XXX mloskot: See comment for GEOSPolygonize_r
-
- std::vector> linevec(lines.size());
-
- for(std::size_t i = 0, n = lines.size(); i < n; ++i) {
- linevec[i] = lines[i]->clone();
- }
-
- auto out = gf->createGeometryCollection(std::move(linevec));
- out->setSRID(srid);
-
- return out.release();
- });
- }
-
- Geometry*
- GEOSPolygonize_full_r(GEOSContextHandle_t extHandle, const Geometry* g,
- Geometry** cuts, Geometry** dangles, Geometry** invalid)
- {
- using geos::operation::polygonize::Polygonizer;
-
- return execute(extHandle, [&]() {
- // Polygonize
- Polygonizer plgnzr;
- for(std::size_t i = 0; i < g->getNumGeometries(); ++i) {
- plgnzr.add(g->getGeometryN(i));
- }
-
- const GeometryFactory* gf = g->getFactory();
-
- if(cuts) {
- const std::vector& lines = plgnzr.getCutEdges();
- std::vector> linevec(lines.size());
- for(std::size_t i = 0, n = lines.size(); i < n; ++i) {
- linevec[i] = lines[i]->clone();
- }
-
- *cuts = gf->createGeometryCollection(std::move(linevec)).release();
- }
-
- if(dangles) {
- const std::vector& lines = plgnzr.getDangles();
- std::vector> linevec(lines.size());
- for(std::size_t i = 0, n = lines.size(); i < n; ++i) {
- linevec[i] = lines[i]->clone();
- }
-
- *dangles = gf->createGeometryCollection(std::move(linevec)).release();
- }
-
- if(invalid) {
- const std::vector>& lines = plgnzr.getInvalidRingLines();
- std::vector> linevec(lines.size());
- for(std::size_t i = 0, n = lines.size(); i < n; ++i) {
- linevec[i] = lines[i]->clone();
- }
-
- *invalid = gf->createGeometryCollection(std::move(linevec)).release();
- }
-
- auto polys = plgnzr.getPolygons();
- Geometry* out = gf->createGeometryCollection(std::move(polys)).release();
- out->setSRID(g->getSRID());
- return out;
- });
- }
-
- Geometry*
- GEOSLineMerge_r(GEOSContextHandle_t extHandle, const Geometry* g)
- {
- using geos::operation::linemerge::LineMerger;
-
- return execute(extHandle, [&]() {
- GEOSContextHandleInternal_t* handle = reinterpret_cast