Skip to content

Commit

Permalink
Merge branch 'branch-6-2'
Browse files Browse the repository at this point in the history
  • Loading branch information
tbonfort committed Jul 16, 2012
2 parents cd81b87 + 64ef556 commit 2fadbde
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
40 changes: 16 additions & 24 deletions mappostgis.c
Expand Up @@ -323,9 +323,8 @@ wkbReadLine(wkbObj *w, lineObj *line)
static void
wkbSkipGeometry(wkbObj *w)
{
char endian;
int type, npoints, nrings, ngeoms, i;
endian = wkbReadChar(w);
/*endian = */wkbReadChar(w);
type = wkbTypeMap(w,wkbReadInt(w));
switch(type) {
case WKB_POINT:
Expand Down Expand Up @@ -364,11 +363,10 @@ wkbSkipGeometry(wkbObj *w)
static int
wkbConvPointToShape(wkbObj *w, shapeObj *shape)
{
char endian;
int type;
lineObj line;

endian = wkbReadChar(w);
/*endian = */wkbReadChar(w);
type = wkbTypeMap(w,wkbReadInt(w));

if( type != WKB_POINT ) return MS_FAILURE;
Expand All @@ -387,11 +385,10 @@ wkbConvPointToShape(wkbObj *w, shapeObj *shape)
static int
wkbConvLineStringToShape(wkbObj *w, shapeObj *shape)
{
char endian;
int type;
lineObj line;

endian = wkbReadChar(w);
/*endian = */wkbReadChar(w);
type = wkbTypeMap(w,wkbReadInt(w));

if( type != WKB_LINESTRING ) return MS_FAILURE;
Expand All @@ -408,12 +405,11 @@ wkbConvLineStringToShape(wkbObj *w, shapeObj *shape)
static int
wkbConvPolygonToShape(wkbObj *w, shapeObj *shape)
{
char endian;
int type;
int i, nrings;
lineObj line;

endian = wkbReadChar(w);
/*endian = */wkbReadChar(w);
type = wkbTypeMap(w,wkbReadInt(w));

if( type != WKB_POLYGON ) return MS_FAILURE;
Expand All @@ -438,12 +434,11 @@ wkbConvPolygonToShape(wkbObj *w, shapeObj *shape)
static int
wkbConvCurvePolygonToShape(wkbObj *w, shapeObj *shape)
{
char endian;
int type, i, ncomponents;
int failures = 0;
int was_poly = ( shape->type == MS_SHAPE_POLYGON );

endian = wkbReadChar(w);
/*endian = */wkbReadChar(w);
type = wkbTypeMap(w,wkbReadInt(w));
ncomponents = wkbReadInt(w);

Expand Down Expand Up @@ -476,11 +471,10 @@ wkbConvCurvePolygonToShape(wkbObj *w, shapeObj *shape)
static int
wkbConvCircularStringToShape(wkbObj *w, shapeObj *shape)
{
char endian;
int type;
lineObj line = {0, NULL};

endian = wkbReadChar(w);
/*endian = */wkbReadChar(w);
type = wkbTypeMap(w,wkbReadInt(w));

if( type != WKB_CIRCULARSTRING ) return MS_FAILURE;
Expand Down Expand Up @@ -510,13 +504,12 @@ wkbConvCircularStringToShape(wkbObj *w, shapeObj *shape)
static int
wkbConvCompoundCurveToShape(wkbObj *w, shapeObj *shape)
{
char endian;
int npoints = 0;
int type, ncomponents, i, j;
lineObj *line;
shapeObj shapebuf;

endian = wkbReadChar(w);
/*endian = */wkbReadChar(w);
type = wkbTypeMap(w,wkbReadInt(w));

/* Init our shape buffer */
Expand Down Expand Up @@ -581,12 +574,11 @@ wkbConvCompoundCurveToShape(wkbObj *w, shapeObj *shape)
static int
wkbConvCollectionToShape(wkbObj *w, shapeObj *shape)
{
char endian;
int type, i, ncomponents;
int i, ncomponents;
int failures = 0;

endian = wkbReadChar(w);
type = wkbTypeMap(w,wkbReadInt(w));
/*endian = */wkbReadChar(w);
/*type = */wkbTypeMap(w,wkbReadInt(w));
ncomponents = wkbReadInt(w);

/*
Expand Down Expand Up @@ -790,7 +782,7 @@ arcStrokeCircle(const pointObj *p1, const pointObj *p2, const pointObj *p3,
double radius; /* Radius of our circular arc */
double sweep_angle_r; /* Total angular size of our circular arc in radians */
double segment_angle_r; /* Segment angle in radians */
double a1, a2, a3; /* Angles represented by p1, p2, p3 relative to center */
double a1, /*a2,*/ a3; /* Angles represented by p1, p2, p3 relative to center */
int side = arcSegmentSide(p1, p3, p2); /* What side of p1,p3 is the middle point? */
int num_edges; /* How many edges we will be generating */
double current_angle_r; /* What angle are we generating now (radians)? */
Expand All @@ -817,7 +809,9 @@ arcStrokeCircle(const pointObj *p1, const pointObj *p2, const pointObj *p3,

/* Calculate the angles that our three points represent */
a1 = atan2(p1->y - center.y, p1->x - center.x);
/* UNUSED
a2 = atan2(p2->y - center.y, p2->x - center.x);
*/
a3 = atan2(p3->y - center.y, p3->x - center.x);
segment_angle_r = M_PI * segment_angle / 180.0;

Expand Down Expand Up @@ -2599,9 +2593,8 @@ int msPostGISLayerNextShape(layerObj *layer, shapeObj *shape)
*/
while (shape->type == MS_SHAPE_NULL) {
if (layerinfo->rownum < PQntuples(layerinfo->pgresult)) {
int rv;
/* Retrieve this shape, cursor access mode. */
rv = msPostGISReadShape(layer, shape);
msPostGISReadShape(layer, shape);
if( shape->type != MS_SHAPE_NULL ) {
(layerinfo->rownum)++; /* move to next shape */
return MS_SUCCESS;
Expand Down Expand Up @@ -2637,7 +2630,6 @@ int msPostGISLayerGetShape(layerObj *layer, shapeObj *shape, resultObj *record)

PGresult *pgresult = NULL;
msPostGISLayerInfo *layerinfo = NULL;
int result = MS_SUCCESS;

long shapeindex = record->shapeindex;
int resultindex = record->resultindex;
Expand Down Expand Up @@ -2689,7 +2681,7 @@ int msPostGISLayerGetShape(layerObj *layer, shapeObj *shape, resultObj *record)
shape->type = MS_SHAPE_NULL;

/* Return the shape, cursor access mode. */
result = msPostGISReadShape(layer, shape);
msPostGISReadShape(layer, shape);

return (shape->type == MS_SHAPE_NULL) ? MS_FAILURE : MS_SUCCESS;
} else { /* no resultindex, fetch the shape from the DB */
Expand Down Expand Up @@ -2755,7 +2747,7 @@ int msPostGISLayerGetShape(layerObj *layer, shapeObj *shape, resultObj *record)

if (num_tuples > 0) {
/* Get shape in random access mode. */
result = msPostGISReadShape(layer, shape);
msPostGISReadShape(layer, shape);
}

return (shape->type == MS_SHAPE_NULL) ? MS_FAILURE : ( (num_tuples > 0) ? MS_SUCCESS : MS_DONE );
Expand Down
11 changes: 10 additions & 1 deletion maputil.c
Expand Up @@ -1234,8 +1234,10 @@ pointObj *msGetMeasureUsingPoint(shapeObj *shape, pointObj *point)
int i, j = 0;
lineObj line;
pointObj *poIntersectionPt = NULL;
#ifdef USE_POINT_Z_M
double dfFactor = 0;
double dfDistTotal, dfDistToIntersection = 0;
#endif

if (shape && point) {
for (i=0; i<shape->numlines; i++) {
Expand Down Expand Up @@ -1271,6 +1273,7 @@ pointObj *msGetMeasureUsingPoint(shapeObj *shape, pointObj *point)
/* -------------------------------------------------------------------- */
poIntersectionPt = msIntersectionPointLine(point, &oFirst, &oSecond);
if (poIntersectionPt) {
#ifdef USE_POINT_Z_M
dfDistTotal = sqrt(((oSecond.x - oFirst.x)*(oSecond.x - oFirst.x)) +
((oSecond.y - oFirst.y)*(oSecond.y - oFirst.y)));

Expand All @@ -1281,7 +1284,6 @@ pointObj *msGetMeasureUsingPoint(shapeObj *shape, pointObj *point)

dfFactor = dfDistToIntersection / dfDistTotal;

#ifdef USE_POINT_Z_M
poIntersectionPt->m = oFirst.m + (oSecond.m - oFirst.m)*dfFactor;
#endif

Expand Down Expand Up @@ -1736,7 +1738,13 @@ shapeObj *msOffsetPolyline(shapeObj *p, double offsetx, double offsety)
}

if(offsety == -99) { /* complex calculations */
int ok = 0;
for (i = 0; i < p->numlines; i++) {
if(p->line[i].numpoints<2) {
ret->line[i].numpoints = 0;
continue; /* skip degenerate lines */
}
ok =1;
pointObj old_pt, old_diffdir, old_offdir;
/* initialize old_offdir and old_diffdir, as gcc isn't smart enough to see that it
* is not an error to do so, and prints a warning */
Expand Down Expand Up @@ -1796,6 +1804,7 @@ shapeObj *msOffsetPolyline(shapeObj *p, double offsetx, double offsety)
ret->line=msSmallRealloc(ret->line,ret->line[i].numpoints*sizeof(pointObj));
}
}
if(!ok) ret->numlines = 0; /* all lines where degenerate */
} else { /* normal offset (eg. drop shadow) */
for (i = 0; i < p->numlines; i++) {
for(j=0; j<p->line[i].numpoints; j++) {
Expand Down

0 comments on commit 2fadbde

Please sign in to comment.