Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

osm2pgsql compile error against geos trunk #3299

Closed
openstreetmap-trac opened this issue Jul 23, 2021 · 8 comments
Closed

osm2pgsql compile error against geos trunk #3299

openstreetmap-trac opened this issue Jul 23, 2021 · 8 comments

Comments

@openstreetmap-trac
Copy link

Reporter: springmeyer
[Submitted to the original trac issue database at 7.53am, Wednesday, 20th October 2010]

Building osm2pgsql trunk against geos trunk leads to:

g++    -c -o build_geometry.o build_geometry.cpp
build_geometry.cpp: In function char* get_wkt_simple(osmNode*, int, int):
build_geometry.cpp:67: error: call of overloaded create(int, int) is ambiguous
/usr/local/include/geos/geom/CoordinateSequenceFactory.h:68: note: candidates are: virtual geos::geom::CoordinateSequence* geos::geom::CoordinateSequenceFactory::create(std::vector<geos::geom::Coordinate, std::allocator<geos::geom::Coordinate> >*, size_t) const
/usr/local/include/geos/geom/CoordinateSequenceFactory.h:81: note:                 virtual geos::geom::CoordinateSequence* geos::geom::CoordinateSequenceFactory::create(size_t, size_t) const
build_geometry.cpp: In function size_t get_wkt_split(osmNode*, int, int, double):
build_geometry.cpp:109: error: call of overloaded create(int, int) is ambiguous
/usr/local/include/geos/geom/CoordinateSequenceFactory.h:68: note: candidates are: virtual geos::geom::CoordinateSequence* geos::geom::CoordinateSequenceFactory::create(std::vector<geos::geom::Coordinate, std::allocator<geos::geom::Coordinate> >*, size_t) const
/usr/local/include/geos/geom/CoordinateSequenceFactory.h:81: note:                 virtual geos::geom::CoordinateSequence* geos::geom::CoordinateSequenceFactory::create(size_t, size_t) const
build_geometry.cpp:139: error: call of overloaded create(int, int) is ambiguous
/usr/local/include/geos/geom/CoordinateSequenceFactory.h:68: note: candidates are: virtual geos::geom::CoordinateSequence* geos::geom::CoordinateSequenceFactory::create(std::vector<geos::geom::Coordinate, std::allocator<geos::geom::Coordinate> >*, size_t) const
/usr/local/include/geos/geom/CoordinateSequenceFactory.h:81: note:                 virtual geos::geom::CoordinateSequence* geos::geom::CoordinateSequenceFactory::create(size_t, size_t) const
build_geometry.cpp:151: error: call of overloaded create(int, int) is ambiguous
/usr/local/include/geos/geom/CoordinateSequenceFactory.h:68: note: candidates are: virtual geos::geom::CoordinateSequence* geos::geom::CoordinateSequenceFactory::create(std::vector<geos::geom::Coordinate, std::allocator<geos::geom::Coordinate> >*, size_t) const
/usr/local/include/geos/geom/CoordinateSequenceFactory.h:81: note:                 virtual geos::geom::CoordinateSequence* geos::geom::CoordinateSequenceFactory::create(size_t, size_t) const
build_geometry.cpp: In function size_t build_geometry(int, osmNode**, int*, int, int, double):
build_geometry.cpp:302: error: call of overloaded create(int, int) is ambiguous
/usr/local/include/geos/geom/CoordinateSequenceFactory.h:68: note: candidates are: virtual geos::geom::CoordinateSequence* geos::geom::CoordinateSequenceFactory::create(std::vector<geos::geom::Coordinate, std::allocator<geos::geom::Coordinate> >*, size_t) const
/usr/local/include/geos/geom/CoordinateSequenceFactory.h:81: note:                 virtual geos::geom::CoordinateSequence* geos::geom::CoordinateSequenceFactory::create(size_t, size_t) const
build_geometry.cpp:351: error: call of overloaded create(int, int) is ambiguous
/usr/local/include/geos/geom/CoordinateSequenceFactory.h:68: note: candidates are: virtual geos::geom::CoordinateSequence* geos::geom::CoordinateSequenceFactory::create(std::vector<geos::geom::Coordinate, std::allocator<geos::geom::Coordinate> >*, size_t) const
/usr/local/include/geos/geom/CoordinateSequenceFactory.h:81: note:                 virtual geos::geom::CoordinateSequence* geos::geom::CoordinateSequenceFactory::create(size_t, size_t) const
build_geometry.cpp:363: error: call of overloaded create(int, int) is ambiguous
/usr/local/include/geos/geom/CoordinateSequenceFactory.h:68: note: candidates are: virtual geos::geom::CoordinateSequence* geos::geom::CoordinateSequenceFactory::create(std::vector<geos::geom::Coordinate, std::allocator<geos::geom::Coordinate> >*, size_t) const
/usr/local/include/geos/geom/CoordinateSequenceFactory.h:81: note:                 virtual geos::geom::CoordinateSequence* geos::geom::CoordinateSequenceFactory::create(size_t, size_t) const
make: *** [build_geometry.o] Error 1

I appears that size_t must now be explicitly passed, and this patch seems to fix the problem:

Index: build_geometry.cpp
===================================================================
--- build_geometry.cpp	(revision 23726)
+++ build_geometry.cpp	(working copy)
@@ -64,7 +64,9 @
 
 char *get_wkt_simple(osmNode *nodes, int count, int polygon) {
     GeometryFactory gf;
-    std::auto_ptr<CoordinateSequence> coords(gf.getCoordinateSequenceFactory()->create(0, 2));
+    std::size_t size(0);
+    std::size_t dimension(2);
+    std::auto_ptr<CoordinateSequence> coords(gf.getCoordinateSequenceFactory()->create(size, dimension));
 
     try
     {
@@ -106,7 +108,9 @
 
 size_t get_wkt_split(osmNode *nodes, int count, int polygon, double split_at) {
     GeometryFactory gf;
-    std::auto_ptr<CoordinateSequence> coords(gf.getCoordinateSequenceFactory()->create(0, 2));
+    std::size_t size(0);
+    std::size_t dimension(2);
+    std::auto_ptr<CoordinateSequence> coords(gf.getCoordinateSequenceFactory()->create(size, dimension));
     double area;
     WKTWriter wktw;
     size_t wkt_size = 0;
@@ -136,7 +140,9 @
 
             double distance = 0;
             std::auto_ptr<CoordinateSequence> segment;
-            segment = std::auto_ptr<CoordinateSequence>(gf.getCoordinateSequenceFactory()->create(0, 2));
+            std::size_t size(0);
+            std::size_t dimension(2);
+            segment = std::auto_ptr<CoordinateSequence>(gf.getCoordinateSequenceFactory()->create(size, dimension));
             segment->add(coords->getAt(0));
             for(unsigned i=1; i<coords->getSize(); i++) {
                 segment->add(coords->getAt(i));
@@ -148,7 +154,8 @
                     areas.push_back(0);
                     wkt_size++;
                     distance=0;
-                    segment = std::auto_ptr<CoordinateSequence>(gf.getCoordinateSequenceFactory()->create(0, 2));
+                    
+                    segment = std::auto_ptr<CoordinateSequence>(gf.getCoordinateSequenceFactory()->create(size, dimension));
                     segment->add(coords->getAt(i));
                 }
             }
@@ -299,7 +306,9 @
     try
     {
         for (int c=0; xnodes[c]; c++) {
-            std::auto_ptr<CoordinateSequence> coords(gf.getCoordinateSequenceFactory()->create(0, 2));
+            std::size_t size(0);
+            std::size_t dimension(2);
+            std::auto_ptr<CoordinateSequence> coords(gf.getCoordinateSequenceFactory()->create(size, dimension));
             for (int i = 0; i < xcount[c]; i++) {
                 struct osmNode *nodes = xnodes[c];
                 Coordinate c;
@@ -348,7 +357,9 @
                         //std::cerr << "polygon(" << osm_id << ") is no good: points(" << pline->getNumPoints() << "), closed(" << pline->isClosed() << "). " << writer.write(pline.get()) << std::endl;
                 double distance = 0;
                 std::auto_ptr<CoordinateSequence> segment;
-                segment = std::auto_ptr<CoordinateSequence>(gf.getCoordinateSequenceFactory()->create(0, 2));
+                std::size_t size(0);
+                std::size_t dimension(2);
+                segment = std::auto_ptr<CoordinateSequence>(gf.getCoordinateSequenceFactory()->create(size, dimension));
                 segment->add(pline->getCoordinateN(0));
                 for(unsigned i=1; i<pline->getNumPoints(); i++) {
                     segment->add(pline->getCoordinateN(i));
@@ -360,7 +371,7 @
                         areas.push_back(0);
                         wkt_size++;
                         distance=0;
-                        segment = std::auto_ptr<CoordinateSequence>(gf.getCoordinateSequenceFactory()->create(0, 2));
+                        segment = std::auto_ptr<CoordinateSequence>(gf.getCoordinateSequenceFactory()->create(size, dimension));
                         segment->add(pline->getCoordinateN(i));
                     }
                 }
@openstreetmap-trac
Copy link
Author

Author: jburgess777[at]googlemail.com
[Added to the original trac issue at 6.15pm, Wednesday, 20th October 2010]

That looks OK, but I'll see if I can find a simpler way to do it.

@openstreetmap-trac
Copy link
Author

Author: springmeyer
[Added to the original trac issue at 6.16pm, Wednesday, 20th October 2010]

Great.

it seems like one of the last two changes here may have caused this:

http://trac.osgeo.org/geos/log/trunk/include/geos/geom/CoordinateArraySequenceFactory.h

Also, just tested against geos 3 release and it compiles fine.

@openstreetmap-trac
Copy link
Author

Author: massoo[at]gmail.com
[Added to the original trac issue at 2.25pm, Tuesday, 14th June 2011]

I am receiving the same error while compiling the osm2pgsql trunk. The details are:
os2pgsql: trunk
geos : geos-3.3.0 release

Please help me to resolve

@openstreetmap-trac
Copy link
Author

Author: AMDmi3
[Added to the original trac issue at 12.20am, Thursday, 30th June 2011]

The same problem on FreeBSD after geos updated to 3.3.0. Actually, there are two kinds of errors:

  • error: call of overloaded 'create(int, int)' is ambiguous
  • error: cannot convert from base 'geos::geom::XXX' to derived type 'geos::geom::YYY' via virtual base 'geos::geom::XXX'

The patch attached only fixes the first one (and it can be done in a simpler way), second is more tricky - I've fixed it by adding dynamic_cast's which should deal with virtual inheritance, but I really don't like it. For now, I've only checked whether it builds.

@openstreetmap-trac
Copy link
Author

Author: springmeyer
[Added to the original trac issue at 3.03pm, Tuesday, 12th July 2011]

ping jburgess777

@openstreetmap-trac
Copy link
Author

Author: oschrenk
[Added to the original trac issue at 11.01am, Wednesday, 31st August 2011]

I applied the patch from AMDmi3 and get this error

/usr/bin/cc -std=gnu99 -DHAVE_CONFIG_H -I.  -D_THREAD_SAFE -pthread -I/usr/local/Cellar/postgresql/9.0.4/include -I/usr/include/libxml2 -I/usr/include  -I/usr/local/Cellar/geos/3.3.0/include -I/usr/local/include -DOSM2PGSQL_DATADIR='"/usr/local/share/osm2pgsql"' -Igeos-fallback  -D_THREAD_SAFE -pthread -I/usr/local/Cellar/postgresql/9.0.4/include -I/usr/include/libxml2 -I/usr/include  -I/usr/local/Cellar/geos/3.3.0/include -I/usr/local/include   -DOSM2PGSQL_DATADIR='"/usr/local/share/osm2pgsql"' -DVERSION='"0.80.0"'  -O3 -march=core2 -msse4.1 -w -pipe -MT keyvals.o -MD -MP -MF .deps/keyvals.Tpo -c -o keyvals.o keyvals.c
In file included from middle.h:10,
                 from output.h:13,
                 from expire-tiles.h:4,
                 from expire-tiles.c:16:
osmtypes.h:45: error: expected specifier-qualifier-list before time_t
make[2]: *** [expire-tiles.o] Error 1

I was trying to compile using homebrew using this environment:

==> Environment
HOMEBREW_VERSION: 0.8
HEAD: f818578a529b67d2768323ca132acb220950688a
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_LIBRARY_PATH: /usr/local/Library/Homebrew
Hardware: dual-core 64-bit penryn
OS X: 10.6.8
Kernel Architecture: i386
Ruby: 1.8.7-174
/usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
Xcode: 3.2.4
GCC-4.0: build 5494 
GCC-4.2: build 5664 
LLVM: build 2326 
MacPorts or Fink? false
X11 installed? true
==> Build Flags
CC: /usr/bin/cc => /usr/bin/gcc-4.2
CXX: /usr/bin/c++ => /usr/bin/c++-4.2
LD: /usr/bin/cc => /usr/bin/gcc-4.2
CFLAGS: -O3 -march=core2 -msse4.1 -w -pipe
CXXFLAGS: -O3 -march=core2 -msse4.1 -w -pipe
MAKEFLAGS: -j2

@openstreetmap-trac
Copy link
Author

Author: oschrenk
[Added to the original trac issue at 12.56pm, Wednesday, 31st August 2011]

I added a patch that fixed my problem with the geotypes.h. Cerdit goes to AMDmi3 that solved it

AMDmi3/osm2pgsql@aa7fa00

Thanks!

@openstreetmap-trac
Copy link
Author

Author: amm
[Added to the original trac issue at 7.12pm, Sunday, 25th September 2011]

I have committed a patch by AMDmi3 for this. In case it still doesn't work, please reopen the ticket.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant