[geos-commits] r3812 - in trunk/src: algorithm geom geomgraph/index io operation/buffer operation/linemerge operation/polygonize

svn_geos at osgeo.org svn_geos at osgeo.org
Fri Jun 7 02:13:55 PDT 2013


Author: mloskot
Date: 2013-06-07 02:13:55 -0700 (Fri, 07 Jun 2013)
New Revision: 3812

Modified:
   trunk/src/algorithm/RayCrossingCounter.cpp
   trunk/src/geom/LineString.cpp
   trunk/src/geomgraph/index/SimpleSweepLineIntersector.cpp
   trunk/src/io/WKBWriter.cpp
   trunk/src/operation/buffer/BufferInputLineSimplifier.cpp
   trunk/src/operation/linemerge/LineSequencer.cpp
   trunk/src/operation/polygonize/PolygonizeGraph.cpp
Log:
Correct int and std::size_t mismatch for 64-bit target.

Modified: trunk/src/algorithm/RayCrossingCounter.cpp
===================================================================
--- trunk/src/algorithm/RayCrossingCounter.cpp	2013-06-07 09:10:16 UTC (rev 3811)
+++ trunk/src/algorithm/RayCrossingCounter.cpp	2013-06-07 09:13:55 UTC (rev 3812)
@@ -43,7 +43,7 @@
 {
 	RayCrossingCounter rcc(point);
 
-	for (int i = 1, ni = ring.size(); i < ni; i++) 
+	for (std::size_t i = 1, ni = ring.size(); i < ni; i++) 
 	{
 		const geom::Coordinate & p1 = ring[ i ];
 		const geom::Coordinate & p2 = ring[ i - 1 ];
@@ -62,7 +62,7 @@
 {
 	RayCrossingCounter rcc(point);
 
-	for (int i = 1, ni = ring.size(); i < ni; i++) 
+	for (std::size_t i = 1, ni = ring.size(); i < ni; i++) 
 	{
 		const geom::Coordinate & p1 = *ring[ i ];
 		const geom::Coordinate & p2 = *ring[ i - 1 ];

Modified: trunk/src/geom/LineString.cpp
===================================================================
--- trunk/src/geom/LineString.cpp	2013-06-07 09:10:16 UTC (rev 3811)
+++ trunk/src/geom/LineString.cpp	2013-06-07 09:13:55 UTC (rev 3812)
@@ -236,8 +236,8 @@
 LineString::isCoordinate(Coordinate& pt) const
 {
 	assert(points.get());
-	int npts=points->getSize();
-	for (int i = 0; i<npts; i++) {
+	std::size_t npts=points->getSize();
+	for (std::size_t i = 0; i<npts; i++) {
 		if (points->getAt(i)==pt) {
 			return true;
 		}
@@ -263,8 +263,8 @@
 	double miny = c.y;
 	double maxx = c.x;
 	double maxy = c.y;
-	int npts=points->getSize();
-	for (int i=1; i<npts; i++) {
+	std::size_t npts=points->getSize();
+	for (std::size_t i=1; i<npts; i++) {
 		const Coordinate &c=points->getAt(i);
 		minx = minx < c.x ? minx : c.x;
 		maxx = maxx > c.x ? maxx : c.x;
@@ -330,10 +330,10 @@
 LineString::normalize()
 {
 	assert(points.get());
-	int npts=points->getSize();
-	int n=npts/2;
-	for (int i=0; i<n; i++) {
-		int j = npts - 1 - i;
+	std::size_t npts=points->getSize();
+	std::size_t n=npts/2;
+	for (std::size_t i=0; i<n; i++) {
+		std::size_t j = npts - 1 - i;
 		if (!(points->getAt(i)==points->getAt(j))) {
 			if (points->getAt(i).compareTo(points->getAt(j)) > 0) {
 				CoordinateSequence::reverse(points.get());
@@ -349,11 +349,11 @@
 	const LineString *line=dynamic_cast<const LineString*>(ls);
 	assert(line);
 	// MD - optimized implementation
-	int mynpts=points->getSize();
-	int othnpts=line->points->getSize();
+	std::size_t mynpts=points->getSize();
+	std::size_t othnpts=line->points->getSize();
 	if ( mynpts > othnpts ) return 1;
 	if ( mynpts < othnpts ) return -1;
-	for (int i=0; i<mynpts; i++)
+	for (std::size_t i=0; i<mynpts; i++)
 	{
 		int cmp=points->getAt(i).compareTo(line->points->getAt(i));
 		if (cmp) return cmp;

Modified: trunk/src/geomgraph/index/SimpleSweepLineIntersector.cpp
===================================================================
--- trunk/src/geomgraph/index/SimpleSweepLineIntersector.cpp	2013-06-07 09:10:16 UTC (rev 3811)
+++ trunk/src/geomgraph/index/SimpleSweepLineIntersector.cpp	2013-06-07 09:13:55 UTC (rev 3812)
@@ -86,8 +86,8 @@
 SimpleSweepLineIntersector::add(Edge *edge, void* edgeSet)
 {
 	const CoordinateSequence *pts=edge->getCoordinates();
-	int n=pts->getSize()-1;
-	for(int i=0; i<n; ++i)
+	std::size_t n=pts->getSize()-1;
+	for(std::size_t i=0; i<n; ++i)
 	{
 		SweepLineSegment *ss=new SweepLineSegment(edge, i);
 		SweepLineEvent *insertEvent=new SweepLineEvent(edgeSet, ss->getMinX(), NULL, ss);

Modified: trunk/src/io/WKBWriter.cpp
===================================================================
--- trunk/src/io/WKBWriter.cpp	2013-06-07 09:10:16 UTC (rev 3811)
+++ trunk/src/io/WKBWriter.cpp	2013-06-07 09:13:55 UTC (rev 3812)
@@ -164,7 +164,7 @@
 	writeGeometryType(WKBConstants::wkbPolygon, g.getSRID());
 	writeSRID(g.getSRID());
 	
-	int nholes = g.getNumInteriorRing();
+	std::size_t nholes = g.getNumInteriorRing();
 	writeInt(nholes+1);
 
 	const LineString* ls = g.getExteriorRing();
@@ -174,7 +174,7 @@
 	assert(cs);
 
 	writeCoordinateSequence(*cs, true);
-	for (int i=0; i<nholes; i++)
+	for (std::size_t i=0; i<nholes; i++)
 	{
 		ls = g.getInteriorRingN(i);
 		assert(ls);
@@ -195,11 +195,11 @@
 	writeGeometryType(wkbtype, g.getSRID());
 	writeSRID(g.getSRID());
 	
-	int ngeoms = g.getNumGeometries();
+	std::size_t ngeoms = g.getNumGeometries();
 	writeInt(ngeoms);
 
 	assert(outStream);
-	for (int i=0; i<ngeoms; i++)
+	for (std::size_t i=0; i<ngeoms; i++)
 	{
 		const Geometry* elem = g.getGeometryN(i);
 		assert(elem);
@@ -272,12 +272,12 @@
 WKBWriter::writeCoordinateSequence(const CoordinateSequence &cs,
 	bool sized) 
 {
-	int size = cs.getSize();
+	std::size_t size = cs.getSize();
 	bool is3d=false;
 	if ( outputDimension > 2) is3d = true;
 
 	if (sized) writeInt(size);
-	for (int i=0; i<size; i++) writeCoordinate(cs, i, is3d);
+	for (std::size_t i=0; i<size; i++) writeCoordinate(cs, i, is3d);
 }
 
 void

Modified: trunk/src/operation/buffer/BufferInputLineSimplifier.cpp
===================================================================
--- trunk/src/operation/buffer/BufferInputLineSimplifier.cpp	2013-06-07 09:10:16 UTC (rev 3811)
+++ trunk/src/operation/buffer/BufferInputLineSimplifier.cpp	2013-06-07 09:13:55 UTC (rev 3812)
@@ -113,11 +113,11 @@
 unsigned int
 BufferInputLineSimplifier::findNextNonDeletedIndex(unsigned int index) const
 {
-	unsigned int next = index + 1;
-	const unsigned int len = inputLine.size();
+	std::size_t next = index + 1;
+	const std::size_t len = inputLine.size();
 	while (next < len && isDeleted[next] == DELETE)
 		next++;
-	return next;
+	return static_cast<unsigned int>(next);
 }
 
 /* private */

Modified: trunk/src/operation/linemerge/LineSequencer.cpp
===================================================================
--- trunk/src/operation/linemerge/LineSequencer.cpp	2013-06-07 09:10:16 UTC (rev 3811)
+++ trunk/src/operation/linemerge/LineSequencer.cpp	2013-06-07 09:13:55 UTC (rev 3812)
@@ -65,7 +65,7 @@
 
 	const Coordinate* lastNode = NULL;
 
-	for (unsigned int i=0, n=mls->getNumGeometries(); i<n; ++i)
+	for (std::size_t i=0, n=mls->getNumGeometries(); i<n; ++i)
 	{
 		const LineString* lineptr = \
 			dynamic_cast<const LineString*>(mls->getGeometryN(i));

Modified: trunk/src/operation/polygonize/PolygonizeGraph.cpp
===================================================================
--- trunk/src/operation/polygonize/PolygonizeGraph.cpp	2013-06-07 09:10:16 UTC (rev 3811)
+++ trunk/src/operation/polygonize/PolygonizeGraph.cpp	2013-06-07 09:13:55 UTC (rev 3812)
@@ -382,7 +382,7 @@
 	 * Must use a SIGNED int here to allow for beak condition
 	 * to be true.
 	 */
-	for(int i=edges.size()-1; i>=0; --i)
+	for(int i=static_cast<int>(edges.size())-1; i>=0; --i)
 	{
 		PolygonizeDirectedEdge *de=(PolygonizeDirectedEdge*)edges[i];
 		PolygonizeDirectedEdge *sym=(PolygonizeDirectedEdge*) de->getSym();



More information about the geos-commits mailing list