Opened 8 years ago

Closed 7 years ago

#3299 closed defect (fixed)

osm2pgsql compile error against geos trunk

Reported by: springmeyer Owned by: jburgess777@…
Priority: major Milestone:
Component: osm2pgsql Version:
Keywords: osm2pgsql Cc: dane@…

Description

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:

  • build_geometry.cpp

     
    6464 
    6565char *get_wkt_simple(osmNode *nodes, int count, int polygon) { 
    6666    GeometryFactory gf; 
    67     std::auto_ptr<CoordinateSequence> coords(gf.getCoordinateSequenceFactory()->create(0, 2)); 
     67    std::size_t size(0); 
     68    std::size_t dimension(2); 
     69    std::auto_ptr<CoordinateSequence> coords(gf.getCoordinateSequenceFactory()->create(size, dimension)); 
    6870 
    6971    try 
    7072    { 
     
    106108 
    107109size_t get_wkt_split(osmNode *nodes, int count, int polygon, double split_at) { 
    108110    GeometryFactory gf; 
    109     std::auto_ptr<CoordinateSequence> coords(gf.getCoordinateSequenceFactory()->create(0, 2)); 
     111    std::size_t size(0); 
     112    std::size_t dimension(2); 
     113    std::auto_ptr<CoordinateSequence> coords(gf.getCoordinateSequenceFactory()->create(size, dimension)); 
    110114    double area; 
    111115    WKTWriter wktw; 
    112116    size_t wkt_size = 0; 
     
    136140 
    137141            double distance = 0; 
    138142            std::auto_ptr<CoordinateSequence> segment; 
    139             segment = std::auto_ptr<CoordinateSequence>(gf.getCoordinateSequenceFactory()->create(0, 2)); 
     143            std::size_t size(0); 
     144            std::size_t dimension(2); 
     145            segment = std::auto_ptr<CoordinateSequence>(gf.getCoordinateSequenceFactory()->create(size, dimension)); 
    140146            segment->add(coords->getAt(0)); 
    141147            for(unsigned i=1; i<coords->getSize(); i++) { 
    142148                segment->add(coords->getAt(i)); 
     
    148154                    areas.push_back(0); 
    149155                    wkt_size++; 
    150156                    distance=0; 
    151                     segment = std::auto_ptr<CoordinateSequence>(gf.getCoordinateSequenceFactory()->create(0, 2)); 
     157                     
     158                    segment = std::auto_ptr<CoordinateSequence>(gf.getCoordinateSequenceFactory()->create(size, dimension)); 
    152159                    segment->add(coords->getAt(i)); 
    153160                } 
    154161            } 
     
    299306    try 
    300307    { 
    301308        for (int c=0; xnodes[c]; c++) { 
    302             std::auto_ptr<CoordinateSequence> coords(gf.getCoordinateSequenceFactory()->create(0, 2)); 
     309            std::size_t size(0); 
     310            std::size_t dimension(2); 
     311            std::auto_ptr<CoordinateSequence> coords(gf.getCoordinateSequenceFactory()->create(size, dimension)); 
    303312            for (int i = 0; i < xcount[c]; i++) { 
    304313                struct osmNode *nodes = xnodes[c]; 
    305314                Coordinate c; 
     
    348357                        //std::cerr << "polygon(" << osm_id << ") is no good: points(" << pline->getNumPoints() << "), closed(" << pline->isClosed() << "). " << writer.write(pline.get()) << std::endl; 
    349358                double distance = 0; 
    350359                std::auto_ptr<CoordinateSequence> segment; 
    351                 segment = std::auto_ptr<CoordinateSequence>(gf.getCoordinateSequenceFactory()->create(0, 2)); 
     360                std::size_t size(0); 
     361                std::size_t dimension(2); 
     362                segment = std::auto_ptr<CoordinateSequence>(gf.getCoordinateSequenceFactory()->create(size, dimension)); 
    352363                segment->add(pline->getCoordinateN(0)); 
    353364                for(unsigned i=1; i<pline->getNumPoints(); i++) { 
    354365                    segment->add(pline->getCoordinateN(i)); 
     
    360371                        areas.push_back(0); 
    361372                        wkt_size++; 
    362373                        distance=0; 
    363                         segment = std::auto_ptr<CoordinateSequence>(gf.getCoordinateSequenceFactory()->create(0, 2)); 
     374                        segment = std::auto_ptr<CoordinateSequence>(gf.getCoordinateSequenceFactory()->create(size, dimension)); 
    364375                        segment->add(pline->getCoordinateN(i)); 
    365376                    } 
    366377                } 

Attachments (4)

build_geometry_geos_trunk.patch (3.8 KB) - added by springmeyer 8 years ago.
osm2pgsql-r26200.log (34.7 KB) - added by AMDmi3 7 years ago.
Log of osm2pgsql build failure with geos-3.3.0 on FreeBSD
patch-build_geometry.cpp (4.4 KB) - added by AMDmi3 7 years ago.
Potential fix for geos-3.3.0
osmtypes.patch (322 bytes) - added by oschrenk 7 years ago.

Download all attachments as: .zip

Change History (13)

Changed 8 years ago by springmeyer

comment:1 Changed 8 years ago by jburgess777@…

  • Owner changed from tom@… to jburgess777@…
  • Status changed from new to assigned

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

comment:2 Changed 8 years ago by springmeyer

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.

comment:3 Changed 7 years ago by massoo@…

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

comment:4 Changed 7 years ago by AMDmi3

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.

Changed 7 years ago by AMDmi3

Log of osm2pgsql build failure with geos-3.3.0 on FreeBSD

Changed 7 years ago by AMDmi3

Potential fix for geos-3.3.0

comment:5 Changed 7 years ago by springmeyer

  • Cc dane@… added

ping jburgess777

comment:6 Changed 7 years ago by oschrenk

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

Changed 7 years ago by oschrenk

comment:7 Changed 7 years ago by oschrenk

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

https://github.com/AMDmi3/osm2pgsql/commit/aa7fa00ab4464a83fa6ea1933bb4353be3cea39d

Thanks!

comment:8 Changed 7 years ago by TomH

  • Component changed from utils to osm2pgsql

comment:9 Changed 7 years ago by amm

  • Resolution set to fixed
  • Status changed from assigned to closed

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

Note: See TracTickets for help on using tickets.