[geos-devel] GEOS and VC++ 2005
strk at refractions.net
strk at refractions.net
Sun Jan 8 08:55:36 EST 2006
Thank you.
During my changes I found anther way to define
container-related things, which seems to me
more consistent with C++ practice:
class EdgeIntersectionList {
public:
typedef set<...> container;
typedef container::iterator iterator;
typedef container::const_iterator const_iterator;
...
}
I've used this with other classes (EdgeEndStar, for example).
Do you think we should use this format for all classes ?
I'd say we do, unless there are known platform on which
this is unsupported.
--strk;
On Sat, Jan 07, 2006 at 05:09:20PM -0700, Charlie Savage wrote:
> Hi everyone,
>
> I'm trying to compile GEOS HEAD using Visual C++ 2005. I had to patch a
> couple files, which I explain below (patch is also attached below).
>
> There is however a more fundamental issue which is setting up the right
> exports for libgeos.dll. This is generally done via
> dllexport/dllimport, just like in libgeos_c. Since libgeos.dll exports
> C++ classes, you can dllexport all the classes. Of course any such
> exported classes can only be used by code compiled by VC++ due to C++
> name mangling. The same if also true if you are using any other
> compiler, for example MingW, to build libgeos.dll - it can only be
> linked against by MinGW.
>
> Anyway, there are few solutions. First, do nothing and disallow the
> creation of dlls using VC++ (you could build static libraries instead).
> Second, add the right dllExport/dllImport macros to the class
> definitions. Third, and what I did, manually construct a def file by
> using information extracted from the dll by dumpbin or the VC++ /MAP
> option. The third option isn't very good because it is manually
> intensive and fairly brittle - although I suppose you could automate it
> using a fair bit of scripting magic.
>
> Anyway, being able to build geos with VC++ is useful, because it makes
> it easier to build extensions for Ruby and Python, both of which are
> compiled using VC++ on Windows.
>
> Just my two cents.
>
> Thanks,
>
> Charlie
>
> -------------------------------
>
> The following patches are needed to build GEOS with Visual Studio C++
> 2005. I've tested them against both VC++ and MinGW on Windows. Note I
> have also created updated Visual Studio C++ if anyone is interested
> (the old that was removed from CVS no longer works).
>
> 1. The main issue is from geomgraph.h, lines 490 and 491:
>
> EdgeIntersectionListIterator begin() const { return nodeMap.begin(); }
> EdgeIntersectionListIterator end() const { return nodeMap.end(); }
>
> Where:
>
> typedef set<EdgeIntersection *, EdgeIntersectionLessThen>::iterator
> EdgeIntersectionListIterator;
>
> VC++ does not compile this because it complains that a non-const
> iterator is being returned from a function that is marked const. It
> seems to me that VC++ is correct, and this should not be allowed. The
> fix is easy enough, return an const_iterator (which I called
> EdgeIntersectionListIterator Const) instead of a iterator. This then
> effects a couple of places in the code.
>
> 2. geos_c.cpp, line 1570.
>
> return (finite(az) && az != DoubleNotANumber);
>
> There is not a finite function, but there is a FINITE macro. So I
> switched to the macro.
>
> 3. GeometricShapeFactory, line 202
>
> if (angSize <= 0.0 || angSize > 2 * M_PI) //3.14159265358979
>
> M_PI does not seem defined on Windows, so I defined it at the top of the
> file.
>
> Thanks,
>
> Charlie
>
> -----------------------------------------------
>
> Index: source/geomgraph/EdgeIntersectionList.cpp
> ===================================================================
> RCS file: /home/cvs/postgis/geos/source/geomgraph/EdgeIntersectionList.cpp,v
> retrieving revision 1.16
> diff -u -r1.16 EdgeIntersectionList.cpp
> --- source/geomgraph/EdgeIntersectionList.cpp 8 Dec 2005 01:11:29
> -0000 1.16
> +++ source/geomgraph/EdgeIntersectionList.cpp 7 Jan 2006 23:48:53 -0000
> @@ -65,7 +65,7 @@
> bool
> EdgeIntersectionList::isIntersection(const Coordinate& pt) const
> {
> - EdgeIntersectionListIterator it=nodeMap.begin(), endIt=nodeMap.end();
> + EdgeIntersectionListIteratorConst it=nodeMap.begin(),
> endIt=nodeMap.end();
> for (; it!=endIt; ++it)
> {
> EdgeIntersection *ei=*it;
> @@ -158,7 +158,7 @@
> EdgeIntersectionList::print() const
> {
> string out="Intersections: ";
> - EdgeIntersectionListIterator it=begin(), endIt=end();
> + EdgeIntersectionListIteratorConst it=begin(), endIt=end();
> for (; it!=endIt; ++it) {
> EdgeIntersection *ei=*it;
> out+=ei->print();
> Index: source/util/GeometricShapeFactory.cpp
> ===================================================================
> RCS file: /home/cvs/postgis/geos/source/util/GeometricShapeFactory.cpp,v
> retrieving revision 1.8
> diff -u -r1.8 GeometricShapeFactory.cpp
> --- source/util/GeometricShapeFactory.cpp 8 Dec 2004 13:54:44
> -0000 1.8
> +++ source/util/GeometricShapeFactory.cpp 7 Jan 2006 23:48:53 -0000
> @@ -17,6 +17,10 @@
> #include <geos/util.h>
> #include <stdio.h>
>
> +#ifndef M_PI
> +#define M_PI 3.14159265358979323846
> +#endif
> +
> namespace geos {
>
> /*
> Index: source/headers/geos/geomgraph.h
> ===================================================================
> RCS file: /home/cvs/postgis/geos/source/headers/geos/geomgraph.h,v
> retrieving revision 1.26
> diff -u -r1.26 geomgraph.h
> --- source/headers/geos/geomgraph.h 7 Dec 2005 19:18:23 -0000 1.26
> +++ source/headers/geos/geomgraph.h 7 Jan 2006 23:48:53 -0000
> @@ -464,6 +464,7 @@
> };
>
> typedef set<EdgeIntersection *, EdgeIntersectionLessThen>::iterator
> EdgeIntersectionListIterator;
> +typedef set<EdgeIntersection *,
> EdgeIntersectionLessThen>::const_iterator EdgeIntersectionListIteratorConst;
>
> /**
> * A list of edge intersections along an Edge.
> @@ -486,8 +487,8 @@
>
> EdgeIntersectionListIterator begin() { return nodeMap.begin(); }
> EdgeIntersectionListIterator end() { return nodeMap.end(); }
> - EdgeIntersectionListIterator begin() const { return nodeMap.begin(); }
> - EdgeIntersectionListIterator end() const { return nodeMap.end(); }
> + EdgeIntersectionListIteratorConst begin() const { return
> nodeMap.begin(); }
> + EdgeIntersectionListIteratorConst end() const { return nodeMap.end(); }
>
> bool isEmpty() const;
> bool isIntersection(const Coordinate& pt) const;
> Index: source/capi/geos_c.cpp
> ===================================================================
> RCS file: /home/cvs/postgis/geos/source/capi/geos_c.cpp,v
> retrieving revision 1.19
> diff -u -r1.19 geos_c.cpp
> --- source/capi/geos_c.cpp 13 Dec 2005 23:03:25 -0000 1.19
> +++ source/capi/geos_c.cpp 7 Jan 2006 23:48:53 -0000
> @@ -1567,7 +1567,7 @@
> double az = g->getCoordinate()->z;
> //sprintf(msg, "ZCoord: %g", az);
> //ERROR_MESSAGE(msg);
> - return (finite(az) && az != DoubleNotANumber);
> + return (FINITE(az) && az != DoubleNotANumber);
> }
>
> int
>
>
> _______________________________________________
> geos-devel mailing list
> geos-devel at geos.refractions.net
> http://geos.refractions.net/mailman/listinfo/geos-devel
--
/"\ ASCII Ribbon Campaign
\ / Respect for low technology.
X Keep e-mail messages readable by any computer system.
/ \ Keep it ASCII.
More information about the geos-devel
mailing list