--- C:\Projects\mapserver-buildkit\mapserver-nightly\mapogr.cpp 2009-02-06 11:05:46.058447100 -0500 +++ C:\Projects\mapserver-buildkit\mapserver-nightly\mapogr.cpp.old 2009-01-29 18:34:30.000000000 -0500 @@ -15,16 +15,16 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in + * + * The above copyright notice and this permission notice shall be included in * all copies of this Software or works derived from this Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. **********************************************************************/ @@ -46,8 +46,8 @@ # define ACQUIRE_OLD_OGR_LOCK msAcquireLock( TLOCK_OGR ) # define RELEASE_OLD_OGR_LOCK msReleaseLock( TLOCK_OGR ) #else -# define ACQUIRE_OLD_OGR_LOCK -# define RELEASE_OLD_OGR_LOCK +# define ACQUIRE_OLD_OGR_LOCK +# define RELEASE_OLD_OGR_LOCK #endif #define ACQUIRE_OGR_LOCK msAcquireLock( TLOCK_OGR ) @@ -79,7 +79,7 @@ static int msOGRLayerIsOpen(layerObj *layer); static int msOGRLayerInitItemInfo(layerObj *layer); -static int msOGRLayerGetAutoStyle(mapObj *map, layerObj *layer, classObj *c, +static int msOGRLayerGetAutoStyle(mapObj *map, layerObj *layer, classObj *c, int tile, long record); static void msOGRCloseConnection( void *conn_handle ); @@ -92,9 +92,9 @@ * * NOTE: This function assumes the line->point array already has been * allocated large enough for the point to be added, but that numpoints - * does not include this new point. + * does not include this new point. **********************************************************************/ -static void ogrPointsAddPoint(lineObj *line, double dX, double dY, +static void ogrPointsAddPoint(lineObj *line, double dX, double dY, int lineindex, rectObj *bounds) { /* Keep track of shape bounds */ @@ -123,12 +123,12 @@ /********************************************************************** * ogrGeomPoints() **********************************************************************/ -static int ogrGeomPoints(OGRGeometryH hGeom, shapeObj *outshp) +static int ogrGeomPoints(OGRGeometryH hGeom, shapeObj *outshp) { int i; int numpoints; - if (hGeom == NULL) + if (hGeom == NULL) return 0; OGRwkbGeometryType eGType = wkbFlatten( OGR_G_GetGeometryType( hGeom ) ); @@ -147,12 +147,12 @@ /* Treat it as GeometryCollection */ for (int iGeom=0; iGeom < OGR_G_GetGeometryCount( hGeom ); iGeom++ ) { - if( ogrGeomPoints( OGR_G_GetGeometryRef( hGeom, iGeom ), + if( ogrGeomPoints( OGR_G_GetGeometryRef( hGeom, iGeom ), outshp ) == -1 ) return -1; } - return 0; + return 0; } break; @@ -165,8 +165,8 @@ default: /* There shouldn't be any more cases should there? */ - msSetError(MS_OGRERR, - "OGRGeometry type `%s' not supported yet.", + msSetError(MS_OGRERR, + "OGRGeometry type `%s' not supported yet.", "ogrGeomPoints()", OGR_G_GetGeometryName( hGeom ) ); return(-1); @@ -180,7 +180,7 @@ { numpoints = 1; } - else if ( eGType == wkbLineString + else if ( eGType == wkbLineString || eGType == wkbLinearRing ) { numpoints = OGR_G_GetPointCount( hGeom ); @@ -191,27 +191,27 @@ } else { - msSetError(MS_OGRERR, - "OGRGeometry type `%s' not supported yet.", + msSetError(MS_OGRERR, + "OGRGeometry type `%s' not supported yet.", "ogrGeomPoints()", OGR_G_GetGeometryName( hGeom ) ); return(-1); } /* ------------------------------------------------------------------ - * Do we need to allocate a line object to contain all our points? + * Do we need to allocate a line object to contain all our points? * ------------------------------------------------------------------ */ if( outshp->numlines == 0 ) { lineObj newline; - + newline.numpoints = 0; newline.point = NULL; msAddLine(outshp, &newline); } - + /* ------------------------------------------------------------------ - * Extend the point array for the new of points to add from the + * Extend the point array for the new of points to add from the * current geometry. * ------------------------------------------------------------------ */ lineObj *line = outshp->line + outshp->numlines-1; @@ -219,25 +219,25 @@ if( line->point == NULL ) line->point = (pointObj *) malloc(sizeof(pointObj) * numpoints); else - line->point = (pointObj *) + line->point = (pointObj *) realloc(line->point,sizeof(pointObj) * (numpoints+line->numpoints)); - - if(!line->point) + + if(!line->point) { - msSetError(MS_MEMERR, "Unable to allocate temporary point cache.", + msSetError(MS_MEMERR, "Unable to allocate temporary point cache.", "ogrGeomPoints()"); return(-1); } - + /* ------------------------------------------------------------------ * alloc buffer and filter/transform points * ------------------------------------------------------------------ */ if( eGType == wkbPoint ) { - ogrPointsAddPoint(line, OGR_G_GetX(hGeom, 0), OGR_G_GetY(hGeom, 0), + ogrPointsAddPoint(line, OGR_G_GetX(hGeom, 0), OGR_G_GetY(hGeom, 0), outshp->numlines-1, &(outshp->bounds)); } - else if( eGType == wkbLineString + else if( eGType == wkbLineString || eGType == wkbLinearRing ) { for(i=0; itype == MS_SHAPE_NULL) @@ -289,7 +289,7 @@ /* Treat it as GeometryCollection */ for (int iGeom=0; iGeom < OGR_G_GetGeometryCount( hGeom ); iGeom++ ) { - if( ogrGeomLine( OGR_G_GetGeometryRef( hGeom, iGeom ), + if( ogrGeomLine( OGR_G_GetGeometryRef( hGeom, iGeom ), outshp, bCloseRings ) == -1 ) return -1; } @@ -318,16 +318,16 @@ line.numpoints = 0; line.point = (pointObj *)malloc(sizeof(pointObj)*(numpoints+1)); - if(!line.point) + if(!line.point) { - msSetError(MS_MEMERR, "Unable to allocate temporary point cache.", + msSetError(MS_MEMERR, "Unable to allocate temporary point cache.", "ogrGeomLine"); return(-1); } for(j=0; jtype = MS_SHAPE_NULL **********************************************************************/ static int ogrConvertGeometry(OGRGeometryH hGeom, shapeObj *outshp, - enum MS_LAYER_TYPE layertype) + enum MS_LAYER_TYPE layertype) { /* ------------------------------------------------------------------ * Process geometry according to layer type @@ -394,7 +394,7 @@ return MS_SUCCESS; } - switch(layertype) + switch(layertype) { /* ------------------------------------------------------------------ * POINT layer - Any geometry can be converted to point/multipoint @@ -455,7 +455,7 @@ break; default: - msSetError(MS_MISCERR, "Unknown or unsupported layer type.", + msSetError(MS_MISCERR, "Unknown or unsupported layer type.", "msOGRLayerNextShape()"); nStatus = MS_FAILURE; } /* switch layertype */ @@ -466,7 +466,7 @@ /********************************************************************** * msOGRGeometryToShape() * - * Utility function to convert from OGR geometry to a mapserver shape + * Utility function to convert from OGR geometry to a mapserver shape * object. **********************************************************************/ int msOGRGeometryToShape(OGRGeometryH hGeometry, shapeObj *psShape, @@ -494,49 +494,16 @@ // Special field index codes for handling text string and angle coming from // OGR style strings. -#define MSOGR_LABELNUMITEMS 21 -#define MSOGR_LABELFONTNAMENAME "OGR:LabelFont" -#define MSOGR_LABELFONTNAMEINDEX -100 -#define MSOGR_LABELSIZENAME "OGR:LabelSize" -#define MSOGR_LABELSIZEINDEX -101 -#define MSOGR_LABELTEXTSTRINGNAME "OGR:LabelTextString" -#define MSOGR_LABELTEXTSTRINGINDEX -102 -#define MSOGR_LABELANGLENAME "OGR:LabelAngle" -#define MSOGR_LABELANGLEINDEX -103 -#define MSOGR_LABELFCOLORNAME "OGR:LabelFColor" -#define MSOGR_LABELFCOLORINDEX -104 -#define MSOGR_LABELBCOLORNAME "OGR:LabelBColor" -#define MSOGR_LABELBCOLORINDEX -105 -#define MSOGR_LABELPLACEMENTNAME "OGR:LabelPlacement" -#define MSOGR_LABELPLACEMENTINDEX -106 -#define MSOGR_LABELANCHORNAME "OGR:LabelAnchor" -#define MSOGR_LABELANCHORINDEX -107 -#define MSOGR_LABELDXNAME "OGR:LabelDx" -#define MSOGR_LABELDXINDEX -108 -#define MSOGR_LABELDYNAME "OGR:LabelDy" -#define MSOGR_LABELDYINDEX -109 -#define MSOGR_LABELPERPNAME "OGR:LabelPerp" -#define MSOGR_LABELPERPINDEX -110 -#define MSOGR_LABELBOLDNAME "OGR:LabelBold" -#define MSOGR_LABELBOLDINDEX -111 -#define MSOGR_LABELITALICNAME "OGR:LabelItalic" -#define MSOGR_LABELITALICINDEX -112 -#define MSOGR_LABELUNDERLINENAME "OGR:LabelUnderline" -#define MSOGR_LABELUNDERLINEINDEX -113 -#define MSOGR_LABELPRIORITYNAME "OGR:LabelPriority" -#define MSOGR_LABELPRIORITYINDEX -114 -#define MSOGR_LABELSTRIKEOUTNAME "OGR:LabelStrikeout" -#define MSOGR_LABELSTRIKEOUTINDEX -115 -#define MSOGR_LABELSTRETCHNAME "OGR:LabelStretch" -#define MSOGR_LABELSTRETCHINDEX -116 -#define MSOGR_LABELADJHORNAME "OGR:LabelAdjHor" -#define MSOGR_LABELADJHORINDEX -117 -#define MSOGR_LABELADJVERTNAME "OGR:LabelAdjVert" -#define MSOGR_LABELADJVERTINDEX -118 -#define MSOGR_LABELHCOLORNAME "OGR:LabelHColor" -#define MSOGR_LABELHCOLORINDEX -119 -#define MSOGR_LABELOCOLORNAME "OGR:LabelOColor" -#define MSOGR_LABELOCOLORINDEX -120 +#define MSOGR_LABELNUMITEMS 4 +#define MSOGR_LABELTEXTNAME "OGR:LabelText" +#define MSOGR_LABELTEXTINDEX -100 +#define MSOGR_LABELANGLENAME "OGR:LabelAngle" +#define MSOGR_LABELANGLEINDEX -101 +#define MSOGR_LABELSIZENAME "OGR:LabelSize" +#define MSOGR_LABELSIZEINDEX -102 +#define MSOGR_LABELCOLORNAME "OGR:LabelColor" +#define MSOGR_LABELCOLORINDEX -103 + /********************************************************************** * msOGRGetValues() @@ -554,14 +521,14 @@ char **values; int i; - if(layer->numitems == 0) + if(layer->numitems == 0) return(NULL); if(!layer->iteminfo) // Should not happen... but just in case! if (msOGRLayerInitItemInfo(layer) != MS_SUCCESS) return NULL; - if((values = (char **)malloc(sizeof(char *)*layer->numitems)) == NULL) + if((values = (char **)malloc(sizeof(char *)*layer->numitems)) == NULL) { msSetError(MS_MEMERR, NULL, "msOGRGetValues()"); return(NULL); @@ -598,238 +565,51 @@ OGR_ST_Destroy(hStylePart); } int bDefault; - if (itemindexes[i] == MSOGR_LABELFONTNAMEINDEX ) - { - if (hLabelStyle == NULL) - values[i] = strdup("Arial"); - else - values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelFontName, - &bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELFONTNAMENAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELSIZEINDEX) + if (itemindexes[i] == MSOGR_LABELTEXTINDEX) { if (hLabelStyle == NULL) - values[i] = strdup("0"); + values[i] = strdup(""); else - values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelSize, + values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, + OGRSTLabelTextString, &bDefault)); if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELSIZENAME " = \"%s\"\n", values[i]); + msDebug(MSOGR_LABELTEXTNAME " = \"%s\"\n", values[i]); } - else if (itemindexes[i] == MSOGR_LABELTEXTSTRINGINDEX) + else if (itemindexes[i] == MSOGR_LABELANGLEINDEX) { if (hLabelStyle == NULL) - values[i] = strdup(""); + values[i] = strdup("0"); else - values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelTextString, + values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, + OGRSTLabelAngle, &bDefault)); if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELTEXTSTRINGNAME " = \"%s\"\n", values[i]); + msDebug(MSOGR_LABELANGLENAME " = \"%s\"\n", values[i]); } - else if (itemindexes[i] == MSOGR_LABELANGLEINDEX) + else if (itemindexes[i] == MSOGR_LABELSIZEINDEX) { if (hLabelStyle == NULL) values[i] = strdup("0"); else - values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelAngle, + values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, + OGRSTLabelSize, &bDefault)); if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELANGLENAME " = \"%s\"\n", values[i]); + msDebug(MSOGR_LABELSIZENAME " = \"%s\"\n", values[i]); } - else if (itemindexes[i] == MSOGR_LABELFCOLORINDEX) + else if (itemindexes[i] == MSOGR_LABELCOLORINDEX) { if (hLabelStyle == NULL) values[i] = strdup("#000000"); else - values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelFColor, + values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, + OGRSTLabelFColor, &bDefault)); if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELFCOLORNAME " = \"%s\"\n", values[i]); + msDebug(MSOGR_LABELCOLORNAME " = \"%s\"\n", values[i]); } - else if (itemindexes[i] == MSOGR_LABELBCOLORINDEX) - { - if (hLabelStyle == NULL) - values[i] = strdup("#000000"); - else - values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelBColor, - &bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELBCOLORNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELPLACEMENTINDEX) - { - if (hLabelStyle == NULL) - values[i] = strdup(""); - else - values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelPlacement, - &bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELPLACEMENTNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELANCHORINDEX) - { - if (hLabelStyle == NULL) - values[i] = strdup("0"); - else - values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelAnchor, - &bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELANCHORNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELDXINDEX) - { - if (hLabelStyle == NULL) - values[i] = strdup("0"); - else - values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelDx, - &bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELDXNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELDYINDEX) - { - if (hLabelStyle == NULL) - values[i] = strdup("0"); - else - values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelDy, - &bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELDYNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELPERPINDEX) - { - if (hLabelStyle == NULL) - values[i] = strdup("0"); - else - values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelPerp, - &bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELPERPNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELBOLDINDEX) - { - if (hLabelStyle == NULL) - values[i] = strdup("0"); - else - values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelBold, - &bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELBOLDNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELITALICINDEX) - { - if (hLabelStyle == NULL) - values[i] = strdup("0"); - else - values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelItalic, - &bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELITALICNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELUNDERLINEINDEX) - { - if (hLabelStyle == NULL) - values[i] = strdup("0"); - else - values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelUnderline, - &bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELUNDERLINENAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELPRIORITYINDEX) - { - if (hLabelStyle == NULL) - values[i] = strdup("0"); - else - values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelPriority, - &bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELPRIORITYNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELSTRIKEOUTINDEX) - { - if (hLabelStyle == NULL) - values[i] = strdup("0"); - else - values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelStrikeout, - &bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELSTRIKEOUTNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELSTRETCHINDEX) - { - if (hLabelStyle == NULL) - values[i] = strdup("0"); - else - values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelStretch, - &bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELSTRETCHNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELADJHORINDEX) - { - if (hLabelStyle == NULL) - values[i] = strdup(""); - else - values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelAdjHor, - &bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELADJHORNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELADJVERTINDEX) - { - if (hLabelStyle == NULL) - values[i] = strdup(""); - else - values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelAdjVert, - &bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELADJVERTNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELHCOLORINDEX) - { - if (hLabelStyle == NULL) - values[i] = strdup(""); - else - values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelHColor, - &bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELHCOLORNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELOCOLORINDEX) - { - if (hLabelStyle == NULL) - values[i] = strdup(""); - else - values[i] = strdup(OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelOColor, - &bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELOCOLORNAME " = \"%s\"\n", values[i]); - } - else + else { msSetError(MS_OGRERR,"Invalid field index!?!","msOGRGetValues()"); return(NULL); @@ -848,34 +628,14 @@ delete poStylePart; } GBool bDefault; - if (itemindexes[i] == MSOGR_LABELFONTNAMEINDEX) - { - if (poLabelStyle == NULL) - values[i] = strdup("Arial"); - else - values[i] = strdup(poLabelStyle->GetParamStr(OGRSTLabelFontName, - bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELFONTNAMENAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELSIZEINDEX) - { - if (poLabelStyle == NULL) - values[i] = strdup("0"); - else - values[i] = strdup(poLabelStyle->GetParamStr(OGRSTLabelSize, - bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELSIZENAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELTEXTSTRINGINDEX) + if (itemindexes[i] == MSOGR_LABELTEXTINDEX) { if (poLabelStyle == NULL) values[i] = strdup(""); else values[i] = strdup(poLabelStyle->TextString(bDefault)); if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELTEXTSTRINGNAME " = \"%s\"\n", values[i]); + msDebug(MSOGR_LABELTEXTNAME " = \"%s\"\n", values[i]); } else if (itemindexes[i] == MSOGR_LABELANGLEINDEX) { @@ -887,7 +647,17 @@ if (layer->debug >= MS_DEBUGLEVEL_VVV) msDebug(MSOGR_LABELANGLENAME " = \"%s\"\n", values[i]); } - else if (itemindexes[i] == MSOGR_LABELFCOLORINDEX) + else if (itemindexes[i] == MSOGR_LABELSIZEINDEX) + { + if (poLabelStyle == NULL) + values[i] = strdup("0"); + else + values[i] = strdup(poLabelStyle->GetParamStr(OGRSTLabelSize, + bDefault)); + if (layer->debug >= MS_DEBUGLEVEL_VVV) + msDebug(MSOGR_LABELSIZENAME " = \"%s\"\n", values[i]); + } + else if (itemindexes[i] == MSOGR_LABELCOLORINDEX) { if (poLabelStyle == NULL) values[i] = strdup("#000000"); @@ -895,169 +665,9 @@ values[i] = strdup(poLabelStyle->GetParamStr(OGRSTLabelFColor, bDefault)); if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELFCOLORNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELBCOLORINDEX) - { - if (poLabelStyle == NULL) - values[i] = strdup("#000000"); - else - values[i] = strdup(poLabelStyle->GetParamStr(OGRSTLabelBColor, - bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELBCOLORNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELPLACEMENTINDEX) - { - if (poLabelStyle == NULL) - values[i] = strdup(""); - else - values[i] = strdup(poLabelStyle->GetParamStr(OGRSTLabelPlacement, - bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELPLACEMENTNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELANCHORINDEX) - { - if (poLabelStyle == NULL) - values[i] = strdup("0"); - else - values[i] = strdup(poLabelStyle->GetParamStr(OGRSTLabelAnchor, - bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELANCHORNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELDXINDEX) - { - if (poLabelStyle == NULL) - values[i] = strdup("0"); - else - values[i] = strdup(poLabelStyle->GetParamStr(OGRSTLabelDx, - bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELDXNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELDYINDEX) - { - if (poLabelStyle == NULL) - values[i] = strdup("0"); - else - values[i] = strdup(poLabelStyle->GetParamStr(OGRSTLabelDy, - bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELDYNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELPERPINDEX) - { - if (poLabelStyle == NULL) - values[i] = strdup("0"); - else - values[i] = strdup(poLabelStyle->GetParamStr(OGRSTLabelPerp, - bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELPERPNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELBOLDINDEX) - { - if (poLabelStyle == NULL) - values[i] = strdup("0"); - else - values[i] = strdup(poLabelStyle->GetParamStr(OGRSTLabelBold, - bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELBOLDNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELITALICINDEX) - { - if (poLabelStyle == NULL) - values[i] = strdup("0"); - else - values[i] = strdup(poLabelStyle->GetParamStr(OGRSTLabelItalic, - bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELITALICNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELUNDERLINEINDEX) - { - if (poLabelStyle == NULL) - values[i] = strdup("0"); - else - values[i] = strdup(poLabelStyle->GetParamStr(OGRSTLabelUnderline, - bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELUNDERLINENAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELPRIORITYINDEX) - { - if (poLabelStyle == NULL) - values[i] = strdup("0"); - else - values[i] = strdup(poLabelStyle->GetParamStr(OGRSTLabelPriority, - bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELPRIORITYNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELSTRIKEOUTINDEX) - { - if (poLabelStyle == NULL) - values[i] = strdup("0"); - else - values[i] = strdup(poLabelStyle->GetParamStr(OGRSTLabelStrikeout, - bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELSTRIKEOUTNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELSTRETCHINDEX) - { - if (poLabelStyle == NULL) - values[i] = strdup("0"); - else - values[i] = strdup(poLabelStyle->GetParamStr(OGRSTLabelStretch, - bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELSTRETCHNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELADJHORINDEX) - { - if (poLabelStyle == NULL) - values[i] = strdup(""); - else - values[i] = strdup(poLabelStyle->GetParamStr(OGRSTLabelAdjHor, - bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELADJHORNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELADJVERTINDEX) - { - if (poLabelStyle == NULL) - values[i] = strdup(""); - else - values[i] = strdup(poLabelStyle->GetParamStr(OGRSTLabelAdjVert, - bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELADJVERTNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELHCOLORINDEX) - { - if (poLabelStyle == NULL) - values[i] = strdup(""); - else - values[i] = strdup(poLabelStyle->GetParamStr(OGRSTLabelHColor, - bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELHCOLORNAME " = \"%s\"\n", values[i]); - } - else if (itemindexes[i] == MSOGR_LABELOCOLORINDEX) - { - if (poLabelStyle == NULL) - values[i] = strdup(""); - else - values[i] = strdup(poLabelStyle->GetParamStr(OGRSTLabelOColor, - bDefault)); - if (layer->debug >= MS_DEBUGLEVEL_VVV) - msDebug(MSOGR_LABELOCOLORNAME " = \"%s\"\n", values[i]); + msDebug(MSOGR_LABELSIZENAME " = \"%s\"\n", values[i]); } - else + else { msSetError(MS_OGRERR,"Invalid field index!?!","msOGRGetValues()"); return(NULL); @@ -1093,14 +703,14 @@ projectionObj *proj, int debug_flag ) { #ifdef USE_PROJ - // First flush the "auto" name from the projargs[]... + // First flush the "auto" name from the projargs[]... msFreeProjection( proj ); if (hSRS == NULL || OSRIsLocal( hSRS ) ) { - // Dataset had no set projection or is NonEarth (LOCAL_CS)... + // Dataset had no set projection or is NonEarth (LOCAL_CS)... // Nothing else to do. Leave proj empty and no reprojection will happen! - return MS_SUCCESS; + return MS_SUCCESS; } // Export OGR SRS to a PROJ4 string @@ -1141,7 +751,7 @@ * Returns MS_SUCCESS/MS_FAILURE **********************************************************************/ -int msOGCWKT2ProjectionObj( const char *pszWKT, +int msOGCWKT2ProjectionObj( const char *pszWKT, projectionObj *proj, int debug_flag ) @@ -1156,7 +766,7 @@ ACQUIRE_OLD_OGR_LOCK; hSRS = OSRNewSpatialReference( NULL ); - if( !EQUALN(pszWKT,"GEOGCS",6) + if( !EQUALN(pszWKT,"GEOGCS",6) && !EQUALN(pszWKT,"PROJCS",6) && !EQUALN(pszWKT,"LOCAL_CS",8) ) eErr = OSRSetFromUserInput( hSRS, pszWKT ); @@ -1168,7 +778,7 @@ if( eErr != OGRERR_NONE ) { OSRDestroySpatialReference( hSRS ); - msSetError(MS_OGRERR, + msSetError(MS_OGRERR, "Ingestion of WKT string '%s' failed.", "msOGCWKT2ProjectionObj()", pszWKT ); @@ -1180,7 +790,7 @@ OSRDestroySpatialReference( hSRS ); return ms_result; #else - msSetError(MS_OGRERR, + msSetError(MS_OGRERR, "Not implemented since neither OGR nor GDAL is enabled.", "msOGCWKT2ProjectionObj()"); return MS_FAILURE; @@ -1204,7 +814,7 @@ static int bOGRDriversRegistered = MS_FALSE; static msOGRFileInfo * -msOGRFileOpen(layerObj *layer, const char *connection ) +msOGRFileOpen(layerObj *layer, const char *connection ) { char *conn_decrypted = NULL; @@ -1227,7 +837,7 @@ CPLSetConfigOption("GML_FIELDTYPES","ALWAYS_STRING"); bOGRDriversRegistered = MS_TRUE; - + RELEASE_OGR_LOCK; } @@ -1242,7 +852,7 @@ } /* ------------------------------------------------------------------ - * Parse connection string into dataset name, and layer name. + * Parse connection string into dataset name, and layer name. * ------------------------------------------------------------------ */ char *pszDSName = NULL, *pszLayerDef = NULL; @@ -1277,8 +887,8 @@ if( pszDSName == NULL ) { - msSetError(MS_OGRERR, - "Error parsing OGR connection information in layer `%s'", + msSetError(MS_OGRERR, + "Error parsing OGR connection information in layer `%s'", "msOGRFileOpen()", layer->name?layer->name:"(null)" ); return NULL; @@ -1302,39 +912,39 @@ { char szPath[MS_MAXPATHLEN] = ""; const char *pszDSSelectedName = pszDSName; - + if( layer->debug ) msDebug("msOGRFileOpen(%s)...\n", connection); - + CPLErrorReset(); - if (msTryBuildPath3(szPath, layer->map->mappath, + if (msTryBuildPath3(szPath, layer->map->mappath, layer->map->shapepath, pszDSName) != NULL || msTryBuildPath(szPath, layer->map->mappath, pszDSName) != NULL) { /* Use relative path */ pszDSSelectedName = szPath; } - + if( layer->debug ) msDebug("OGROPen(%s)\n", pszDSSelectedName); ACQUIRE_OGR_LOCK; hDS = OGROpen( pszDSSelectedName, MS_FALSE, NULL ); RELEASE_OGR_LOCK; - + if( hDS == NULL ) { if( strlen(CPLGetLastErrorMsg()) == 0 ) - msSetError(MS_OGRERR, + msSetError(MS_OGRERR, "Open failed for OGR connection in layer `%s'. " - "File not found or unsupported format.", + "File not found or unsupported format.", "msOGRFileOpen()", layer->name?layer->name:"(null)" ); else - msSetError(MS_OGRERR, + msSetError(MS_OGRERR, "Open failed for OGR connection in layer `%s'.\n%s\n", - "msOGRFileOpen()", - layer->name?layer->name:"(null)", + "msOGRFileOpen()", + layer->name?layer->name:"(null)", CPLGetLastErrorMsg() ); CPLFree( pszDSName ); CPLFree( pszLayerDef ); @@ -1343,14 +953,14 @@ msConnPoolRegister( layer, hDS, msOGRCloseConnection ); } - + CPLFree( pszDSName ); pszDSName = NULL; /* ------------------------------------------------------------------ * Find the layer selected. * ------------------------------------------------------------------ */ - + int nLayerIndex = 0; OGRLayerH hLayer = NULL; @@ -1359,7 +969,7 @@ for( iLayer = 0; iLayer < OGR_DS_GetLayerCount(hDS); iLayer++ ) { hLayer = OGR_DS_GetLayer( hDS, iLayer ); - if( hLayer != NULL + if( hLayer != NULL && EQUAL(OGR_FD_GetName( OGR_L_GetLayerDefn(hLayer) ),pszLayerDef) ) { nLayerIndex = iLayer; @@ -1368,7 +978,7 @@ else hLayer = NULL; } - + if( hLayer == NULL && (atoi(pszLayerDef) > 0 || EQUAL(pszLayerDef,"0")) ) { nLayerIndex = atoi(pszLayerDef); @@ -1382,9 +992,9 @@ hLayer = OGR_DS_ExecuteSQL( hDS, pszLayerDef, NULL, NULL ); if( hLayer == NULL ) { - msSetError(MS_OGRERR, + msSetError(MS_OGRERR, "ExecuteSQL(%s) failed.\n%s", - "msOGRFileOpen()", + "msOGRFileOpen()", pszLayerDef, CPLGetLastErrorMsg() ); OGR_DS_Destroy( hDS ); CPLFree( pszLayerDef ); @@ -1398,7 +1008,7 @@ if (hLayer == NULL) { msSetError(MS_OGRERR, "GetLayer(%s) failed for OGR connection `%s'.", - "msOGRFileOpen()", + "msOGRFileOpen()", pszLayerDef, connection ); CPLFree( pszLayerDef ); ACQUIRE_OGR_LOCK; @@ -1447,13 +1057,13 @@ /********************************************************************** * msOGRFileClose() **********************************************************************/ -static int msOGRFileClose(layerObj *layer, msOGRFileInfo *psInfo ) +static int msOGRFileClose(layerObj *layer, msOGRFileInfo *psInfo ) { if (!psInfo) return MS_SUCCESS; if( layer->debug ) - msDebug("msOGRFileClose(%s,%d).\n", + msDebug("msOGRFileClose(%s,%d).\n", psInfo->pszFname, psInfo->nLayerIndex); CPLFree(psInfo->pszFname); @@ -1492,11 +1102,11 @@ * layer's FILTER overlaps the selected region. **********************************************************************/ static int msOGRFileWhichShapes(layerObj *layer, rectObj rect, - msOGRFileInfo *psInfo ) + msOGRFileInfo *psInfo ) { if (psInfo == NULL || psInfo->hLayer == NULL) { - msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!", + msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!", "msOGRFileWhichShapes()"); return(MS_FAILURE); } @@ -1505,7 +1115,7 @@ * Set Spatial filter... this may result in no features being returned * if layer does not overlap current view. * - * __TODO__ We should return MS_DONE if no shape overlaps the selected + * __TODO__ We should return MS_DONE if no shape overlaps the selected * region and matches the layer's FILTER expression, but there is currently * no _efficient_ way to do that with OGR. * ------------------------------------------------------------------ */ @@ -1541,9 +1151,9 @@ rect.minx, rect.miny, rect.maxx, rect.maxy ); /* ------------------------------------------------------------------ - * Apply an attribute filter if we have one prefixed with a WHERE + * Apply an attribute filter if we have one prefixed with a WHERE * keyword in the filter string. Otherwise, ensure the attribute - * filter is clear. + * filter is clear. * ------------------------------------------------------------------ */ if( layer->filter.string && EQUALN(layer->filter.string,"WHERE ",6) ) { @@ -1552,9 +1162,9 @@ != OGRERR_NONE ) { msSetError(MS_OGRERR, - "SetAttributeFilter(%s) failed on layer %s.\n%s", + "SetAttributeFilter(%s) failed on layer %s.\n%s", "msOGRFileWhichShapes()", - layer->filter.string+6, layer->name?layer->name:"(null)", + layer->filter.string+6, layer->name?layer->name:"(null)", CPLGetLastErrorMsg() ); RELEASE_OGR_LOCK; return MS_FAILURE; @@ -1587,10 +1197,10 @@ const char *getShapeStyleItems; if((hDefn = OGR_L_GetLayerDefn( psInfo->hLayer )) == NULL || - (totalnumitems = numitems = OGR_FD_GetFieldCount( hDefn )) == 0) + (totalnumitems = numitems = OGR_FD_GetFieldCount( hDefn )) == 0) { - msSetError(MS_OGRERR, - "OGR Connection for layer `%s' contains no fields.", + msSetError(MS_OGRERR, + "OGR Connection for layer `%s' contains no fields.", "msOGRFileGetItems()", layer->name?layer->name:"(null)" ); return NULL; @@ -1600,7 +1210,7 @@ if (getShapeStyleItems && EQUAL(getShapeStyleItems, "all")) totalnumitems += numStyleItems; - if((items = (char**)malloc(sizeof(char *)*(totalnumitems+1))) == NULL) + if((items = (char**)malloc(sizeof(char *)*(totalnumitems+1))) == NULL) { msSetError(MS_MEMERR, NULL, "msOGRFileGetItems()"); return NULL; @@ -1614,28 +1224,11 @@ if (getShapeStyleItems && EQUAL(getShapeStyleItems, "all")) { - assert(numStyleItems == 21); - items[i++] = strdup( MSOGR_LABELFONTNAMENAME ); - items[i++] = strdup( MSOGR_LABELSIZENAME ); - items[i++] = strdup( MSOGR_LABELTEXTSTRINGNAME ); + assert(numStyleItems == 4); + items[i++] = strdup( MSOGR_LABELTEXTNAME ); items[i++] = strdup( MSOGR_LABELANGLENAME ); - items[i++] = strdup( MSOGR_LABELFCOLORNAME ); - items[i++] = strdup( MSOGR_LABELBCOLORNAME ); - items[i++] = strdup( MSOGR_LABELPLACEMENTNAME ); - items[i++] = strdup( MSOGR_LABELANCHORNAME ); - items[i++] = strdup( MSOGR_LABELDXNAME ); - items[i++] = strdup( MSOGR_LABELDYNAME ); - items[i++] = strdup( MSOGR_LABELPERPNAME ); - items[i++] = strdup( MSOGR_LABELBOLDNAME ); - items[i++] = strdup( MSOGR_LABELITALICNAME ); - items[i++] = strdup( MSOGR_LABELUNDERLINENAME ); - items[i++] = strdup( MSOGR_LABELPRIORITYNAME ); - items[i++] = strdup( MSOGR_LABELSTRIKEOUTNAME ); - items[i++] = strdup( MSOGR_LABELSTRETCHNAME ); - items[i++] = strdup( MSOGR_LABELADJHORNAME ); - items[i++] = strdup( MSOGR_LABELADJVERTNAME ); - items[i++] = strdup( MSOGR_LABELHCOLORNAME ); - items[i++] = strdup( MSOGR_LABELOCOLORNAME ); + items[i++] = strdup( MSOGR_LABELSIZENAME ); + items[i++] = strdup( MSOGR_LABELCOLORNAME ); } items[i++] = NULL; @@ -1650,21 +1243,21 @@ * * Returns MS_SUCCESS/MS_FAILURE **********************************************************************/ -static int +static int msOGRFileNextShape(layerObj *layer, shapeObj *shape, - msOGRFileInfo *psInfo ) + msOGRFileInfo *psInfo ) { OGRFeatureH hFeature = NULL; if (psInfo == NULL || psInfo->hLayer == NULL) { - msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!", + msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!", "msOGRFileNextShape()"); return(MS_FAILURE); } /* ------------------------------------------------------------------ - * Read until we find a feature that matches attribute filter and + * Read until we find a feature that matches attribute filter and * whose geometry is compatible with current layer type. * ------------------------------------------------------------------ */ msFreeShape(shape); @@ -1694,7 +1287,7 @@ } } - if(layer->numitems > 0) + if(layer->numitems > 0) { shape->values = msOGRGetValues(layer, hFeature); shape->numvalues = layer->numitems; @@ -1706,10 +1299,10 @@ } } - // Check the expression unless it is a WHERE clause already - // handled by OGR. + // Check the expression unless it is a WHERE clause already + // handled by OGR. if( (layer->filter.string && EQUALN(layer->filter.string,"WHERE ",6)) - || msEvalExpression(&(layer->filter), layer->filteritemindex, + || msEvalExpression(&(layer->filter), layer->filteritemindex, shape->values, layer->numitems) == MS_TRUE) { // Feature matched filter expression... process geometry @@ -1722,8 +1315,8 @@ if (layer->debug >= MS_DEBUGLEVEL_VVV) msDebug("msOGRFileNextShape: Rejecting feature (shapeid = %d, tileid=%d) of incompatible type for this layer (feature wkbType %d, layer type %d)\n", - OGR_F_GetFID( hFeature ), psInfo->nTileId, - wkbFlatten( OGR_G_GetGeometryType( OGR_F_GetGeometryRef( hFeature ) ) ), + OGR_F_GetFID( hFeature ), psInfo->nTileId, + wkbFlatten( OGR_G_GetGeometryType( OGR_F_GetGeometryRef( hFeature ) ) ), layer->type); } @@ -1765,7 +1358,7 @@ * * Returns MS_SUCCESS/MS_FAILURE **********************************************************************/ -static int +static int msOGRFileGetShape(layerObj *layer, shapeObj *shape, long record, msOGRFileInfo *psInfo ) { @@ -1773,13 +1366,13 @@ if (psInfo == NULL || psInfo->hLayer == NULL) { - msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!", + msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!", "msOGRFileNextShape()"); return(MS_FAILURE); } /* ------------------------------------------------------------------ - * Handle shape geometry... + * Handle shape geometry... * ------------------------------------------------------------------ */ msFreeShape(shape); shape->type = MS_SHAPE_NULL; @@ -1798,10 +1391,10 @@ RELEASE_OGR_LOCK; return MS_FAILURE; // Error message already produced. } - + if (shape->type == MS_SHAPE_NULL) { - msSetError(MS_OGRERR, + msSetError(MS_OGRERR, "Requested feature is incompatible with layer type", "msOGRLayerGetShape()"); RELEASE_OGR_LOCK; @@ -1811,7 +1404,7 @@ /* ------------------------------------------------------------------ * Process shape attributes * ------------------------------------------------------------------ */ - if(layer->numitems > 0) + if(layer->numitems > 0) { shape->values = msOGRGetValues(layer, hFeature); shape->numvalues = layer->numitems; @@ -1821,7 +1414,7 @@ return(MS_FAILURE); } - } + } shape->index = OGR_F_GetFID( hFeature ); shape->tileindex = psInfo->nTileId; @@ -1848,7 +1441,7 @@ /* the current rectangle. */ /************************************************************************/ -int msOGRFileReadTile( layerObj *layer, msOGRFileInfo *psInfo, +int msOGRFileReadTile( layerObj *layer, msOGRFileInfo *psInfo, int targetTile = -1 ) { @@ -1873,7 +1466,7 @@ { OGR_L_ResetReading( psInfo->hLayer ); } - + /* -------------------------------------------------------------------- */ /* Get the name (connection string really) of the next tile. */ /* -------------------------------------------------------------------- */ @@ -1888,7 +1481,7 @@ if( targetTile < 0 ) hFeature = OGR_L_GetNextFeature( psInfo->hLayer ); - + else hFeature = OGR_L_GetFeature( psInfo->hLayer, targetTile ); @@ -1899,16 +1492,16 @@ return MS_DONE; else return MS_FAILURE; - + } - connection = strdup( OGR_F_GetFieldAsString( hFeature, + connection = strdup( OGR_F_GetFieldAsString( hFeature, layer->tileitemindex )); - + nFeatureId = OGR_F_GetFID( hFeature ); OGR_F_Destroy( hFeature ); - + RELEASE_OGR_LOCK; /* -------------------------------------------------------------------- */ @@ -1937,9 +1530,9 @@ if( status != MS_SUCCESS ) return status; } - + psInfo->poCurTile = psTileInfo; - + /* -------------------------------------------------------------------- */ /* Update the iteminfo in case this layer has a different field */ /* list. */ @@ -1974,7 +1567,7 @@ * * Returns MS_SUCCESS/MS_FAILURE **********************************************************************/ -int msOGRLayerOpen(layerObj *layer, const char *pszOverrideConnection) +int msOGRLayerOpen(layerObj *layer, const char *pszOverrideConnection) { #ifdef USE_OGR @@ -1990,12 +1583,12 @@ /* -------------------------------------------------------------------- */ if( layer->tileindex == NULL ) { - psInfo = msOGRFileOpen( layer, + psInfo = msOGRFileOpen( layer, (pszOverrideConnection ? pszOverrideConnection: layer->connection) ); layer->layerinfo = psInfo; layer->tileitemindex = -1; - + if( layer->layerinfo == NULL ) return MS_FAILURE; } @@ -2011,24 +1604,24 @@ psInfo = msOGRFileOpen( layer, layer->tileindex ); layer->layerinfo = psInfo; - + if( layer->layerinfo == NULL ) return MS_FAILURE; // Identify TILEITEM OGRFeatureDefnH hDefn = OGR_L_GetLayerDefn( psInfo->hLayer ); - for( layer->tileitemindex = 0; + for( layer->tileitemindex = 0; layer->tileitemindex < OGR_FD_GetFieldCount( hDefn ) && !EQUAL( OGR_Fld_GetNameRef( OGR_FD_GetFieldDefn( hDefn, layer->tileitemindex) ), - layer->tileitem); + layer->tileitem); layer->tileitemindex++ ) {} if( layer->tileitemindex == OGR_FD_GetFieldCount( hDefn ) ) { - msSetError(MS_OGRERR, + msSetError(MS_OGRERR, "Can't identify TILEITEM %s field in TILEINDEX `%s'.", - "msOGRLayerOpen()", + "msOGRLayerOpen()", layer->tileitem, layer->tileindex ); msOGRFileClose( layer, psInfo ); layer->layerinfo = NULL; @@ -2041,7 +1634,7 @@ * For a tile index, it is assume the tile index has the projection. * ------------------------------------------------------------------ */ #ifdef USE_PROJ - if (layer->projection.numargs > 0 && + if (layer->projection.numargs > 0 && EQUAL(layer->projection.args[0], "auto")) { ACQUIRE_OGR_LOCK; @@ -2054,12 +1647,12 @@ errorObj *ms_error = msGetErrorObj(); RELEASE_OGR_LOCK; - msSetError(MS_OGRERR, + msSetError(MS_OGRERR, "%s " "PROJECTION AUTO cannot be used for this " "OGR connection (in layer `%s').", "msOGRLayerOpen()", - ms_error->message, + ms_error->message, layer->name?layer->name:"(null)" ); msOGRFileClose( layer, psInfo ); layer->layerinfo = NULL; @@ -2087,7 +1680,7 @@ * * Overloaded version of msOGRLayerOpen for virtual table architecture **********************************************************************/ -static int msOGRLayerOpenVT(layerObj *layer) +static int msOGRLayerOpenVT(layerObj *layer) { return msOGRLayerOpen(layer, NULL); } @@ -2095,7 +1688,7 @@ /********************************************************************** * msOGRLayerClose() **********************************************************************/ -int msOGRLayerClose(layerObj *layer) +int msOGRLayerClose(layerObj *layer) { #ifdef USE_OGR msOGRFileInfo *psInfo =(msOGRFileInfo*)layer->layerinfo; @@ -2125,7 +1718,7 @@ /********************************************************************** * msOGRLayerIsOpen() **********************************************************************/ -static int msOGRLayerIsOpen(layerObj *layer) +static int msOGRLayerIsOpen(layerObj *layer) { #ifdef USE_OGR if (layer->layerinfo) @@ -2152,7 +1745,7 @@ * Returns MS_SUCCESS/MS_FAILURE, or MS_DONE if no shape matching the * layer's FILTER overlaps the selected region. **********************************************************************/ -int msOGRLayerWhichShapes(layerObj *layer, rectObj rect) +int msOGRLayerWhichShapes(layerObj *layer, rectObj rect) { #ifdef USE_OGR msOGRFileInfo *psInfo =(msOGRFileInfo*)layer->layerinfo; @@ -2160,7 +1753,7 @@ if (psInfo == NULL || psInfo->hLayer == NULL) { - msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!", + msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!", "msOGRLayerWhichShapes()"); return(MS_FAILURE); } @@ -2171,7 +1764,7 @@ return status; // If we are using a tile index, we need to advance to the first - // tile matching the spatial query, and load it. + // tile matching the spatial query, and load it. return msOGRFileReadTile( layer, psInfo ); @@ -2180,7 +1773,7 @@ * OGR Support not included... * ------------------------------------------------------------------ */ - msSetError(MS_MISCERR, "OGR support is not available.", + msSetError(MS_MISCERR, "OGR support is not available.", "msOGRLayerWhichShapes()"); return(MS_FAILURE); @@ -2192,19 +1785,19 @@ * * Load item (i.e. field) names in a char array. If we are working * with a tiled layer, ensure a tile is loaded and use it for the items. - * It is implicitly assumed that the schemas will match on all tiles. + * It is implicitly assumed that the schemas will match on all tiles. **********************************************************************/ int msOGRLayerGetItems(layerObj *layer) { #ifdef USE_OGR msOGRFileInfo *psInfo =(msOGRFileInfo*)layer->layerinfo; - + if( layer->tileindex != NULL ) { - if( psInfo->poCurTile == NULL + if( psInfo->poCurTile == NULL && msOGRFileReadTile( layer, psInfo ) != MS_SUCCESS ) return MS_FAILURE; - + psInfo = psInfo->poCurTile; } @@ -2223,7 +1816,7 @@ * OGR Support not included... * ------------------------------------------------------------------ */ - msSetError(MS_MISCERR, "OGR support is not available.", + msSetError(MS_MISCERR, "OGR support is not available.", "msOGRLayerGetItems()"); return(MS_FAILURE); @@ -2247,89 +1840,55 @@ if( layer->tileindex != NULL ) { - if( psInfo->poCurTile == NULL + if( psInfo->poCurTile == NULL && msOGRFileReadTile( layer, psInfo, -2 ) != MS_SUCCESS ) return MS_FAILURE; - + psInfo = psInfo->poCurTile; } if (psInfo == NULL || psInfo->hLayer == NULL) { - msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!", + msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!", "msOGRLayerInitItemInfo()"); return(MS_FAILURE); } - if((hDefn = OGR_L_GetLayerDefn( psInfo->hLayer )) == NULL) + if((hDefn = OGR_L_GetLayerDefn( psInfo->hLayer )) == NULL) { - msSetError(MS_OGRERR, "Layer contains no fields.", + msSetError(MS_OGRERR, "Layer contains no fields.", "msOGRLayerInitItemInfo()"); return(MS_FAILURE); } if (layer->iteminfo) free(layer->iteminfo); - if((layer->iteminfo = (int *)malloc(sizeof(int)*layer->numitems))== NULL) + if((layer->iteminfo = (int *)malloc(sizeof(int)*layer->numitems))== NULL) { msSetError(MS_MEMERR, NULL, "msOGRLayerInitItemInfo()"); return(MS_FAILURE); } int *itemindexes = (int*)layer->iteminfo; - for(i=0;inumitems;i++) + for(i=0;inumitems;i++) { // Special case for handling text string and angle coming from // OGR style strings. We use special attribute names. - if (EQUAL(layer->items[i], MSOGR_LABELFONTNAMENAME)) - itemindexes[i] = MSOGR_LABELFONTNAMEINDEX; - else if (EQUAL(layer->items[i], MSOGR_LABELSIZENAME)) - itemindexes[i] = MSOGR_LABELSIZEINDEX; - else if (EQUAL(layer->items[i], MSOGR_LABELTEXTSTRINGNAME)) - itemindexes[i] = MSOGR_LABELTEXTSTRINGINDEX; + if (EQUAL(layer->items[i], MSOGR_LABELTEXTNAME)) + itemindexes[i] = MSOGR_LABELTEXTINDEX; else if (EQUAL(layer->items[i], MSOGR_LABELANGLENAME)) itemindexes[i] = MSOGR_LABELANGLEINDEX; - else if (EQUAL(layer->items[i], MSOGR_LABELFCOLORNAME)) - itemindexes[i] = MSOGR_LABELFCOLORINDEX; - else if (EQUAL(layer->items[i], MSOGR_LABELBCOLORNAME)) - itemindexes[i] = MSOGR_LABELBCOLORINDEX; - else if (EQUAL(layer->items[i], MSOGR_LABELPLACEMENTNAME)) - itemindexes[i] = MSOGR_LABELPLACEMENTINDEX; - else if (EQUAL(layer->items[i], MSOGR_LABELANCHORNAME)) - itemindexes[i] = MSOGR_LABELANCHORINDEX; - else if (EQUAL(layer->items[i], MSOGR_LABELDXNAME)) - itemindexes[i] = MSOGR_LABELDXINDEX; - else if (EQUAL(layer->items[i], MSOGR_LABELDYNAME)) - itemindexes[i] = MSOGR_LABELDYINDEX; - else if (EQUAL(layer->items[i], MSOGR_LABELPERPNAME)) - itemindexes[i] = MSOGR_LABELPERPINDEX; - else if (EQUAL(layer->items[i], MSOGR_LABELBOLDNAME)) - itemindexes[i] = MSOGR_LABELBOLDINDEX; - else if (EQUAL(layer->items[i], MSOGR_LABELITALICNAME)) - itemindexes[i] = MSOGR_LABELITALICINDEX; - else if (EQUAL(layer->items[i], MSOGR_LABELUNDERLINENAME)) - itemindexes[i] = MSOGR_LABELUNDERLINEINDEX; - else if (EQUAL(layer->items[i], MSOGR_LABELPRIORITYNAME)) - itemindexes[i] = MSOGR_LABELPRIORITYINDEX; - else if (EQUAL(layer->items[i], MSOGR_LABELSTRIKEOUTNAME)) - itemindexes[i] = MSOGR_LABELSTRIKEOUTINDEX; - else if (EQUAL(layer->items[i], MSOGR_LABELSTRETCHNAME)) - itemindexes[i] = MSOGR_LABELSTRETCHINDEX; - else if (EQUAL(layer->items[i], MSOGR_LABELADJHORNAME)) - itemindexes[i] = MSOGR_LABELADJHORINDEX; - else if (EQUAL(layer->items[i], MSOGR_LABELADJVERTNAME)) - itemindexes[i] = MSOGR_LABELADJVERTINDEX; - else if (EQUAL(layer->items[i], MSOGR_LABELHCOLORNAME)) - itemindexes[i] = MSOGR_LABELHCOLORINDEX; - else if (EQUAL(layer->items[i], MSOGR_LABELOCOLORNAME)) - itemindexes[i] = MSOGR_LABELOCOLORINDEX; + else if (EQUAL(layer->items[i], MSOGR_LABELSIZENAME)) + itemindexes[i] = MSOGR_LABELSIZEINDEX; + else if (EQUAL(layer->items[i], MSOGR_LABELCOLORNAME)) + itemindexes[i] = MSOGR_LABELCOLORINDEX; else itemindexes[i] = OGR_FD_GetFieldIndex( hDefn, layer->items[i] ); if(itemindexes[i] == -1) { - msSetError(MS_OGRERR, - (char*)CPLSPrintf("Invalid Field name: %s", - layer->items[i]), + msSetError(MS_OGRERR, + (char*)CPLSPrintf("Invalid Field name: %s", + layer->items[i]), "msOGRLayerInitItemInfo()"); return(MS_FAILURE); } @@ -2341,7 +1900,7 @@ * OGR Support not included... * ------------------------------------------------------------------ */ - msSetError(MS_MISCERR, "OGR support is not available.", + msSetError(MS_MISCERR, "OGR support is not available.", "msOGRLayerInitItemInfo()"); return(MS_FAILURE); @@ -2366,7 +1925,7 @@ * OGR Support not included... * ------------------------------------------------------------------ */ - msSetError(MS_MISCERR, "OGR support is not available.", + msSetError(MS_MISCERR, "OGR support is not available.", "msOGRLayerFreeItemInfo()"); #endif /* USE_OGR */ @@ -2381,7 +1940,7 @@ * * Returns MS_SUCCESS/MS_FAILURE **********************************************************************/ -int msOGRLayerNextShape(layerObj *layer, shapeObj *shape) +int msOGRLayerNextShape(layerObj *layer, shapeObj *shape) { #ifdef USE_OGR msOGRFileInfo *psInfo =(msOGRFileInfo*)layer->layerinfo; @@ -2389,7 +1948,7 @@ if (psInfo == NULL || psInfo->hLayer == NULL) { - msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!", + msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!", "msOGRLayerNextShape()"); return(MS_FAILURE); } @@ -2397,7 +1956,7 @@ if( layer->tileindex == NULL ) return msOGRFileNextShape( layer, shape, psInfo ); - // Do we need to load the first tile? + // Do we need to load the first tile? if( psInfo->poCurTile == NULL ) { status = msOGRFileReadTile( layer, psInfo ); @@ -2405,13 +1964,13 @@ return status; } - do + do { // Try getting a shape from this tile. status = msOGRFileNextShape( layer, shape, psInfo->poCurTile ); if( status != MS_DONE ) return status; - + // try next tile. status = msOGRFileReadTile( layer, psInfo ); if( status != MS_SUCCESS ) @@ -2419,13 +1978,13 @@ } while( status == MS_SUCCESS ); return status; - + #else /* ------------------------------------------------------------------ * OGR Support not included... * ------------------------------------------------------------------ */ - msSetError(MS_MISCERR, "OGR support is not available.", + msSetError(MS_MISCERR, "OGR support is not available.", "msOGRLayerNextShape()"); return(MS_FAILURE); @@ -2439,7 +1998,7 @@ * * Returns MS_SUCCESS/MS_FAILURE **********************************************************************/ -int msOGRLayerGetShape(layerObj *layer, shapeObj *shape, int tile, +int msOGRLayerGetShape(layerObj *layer, shapeObj *shape, int tile, long record) { #ifdef USE_OGR @@ -2447,7 +2006,7 @@ if (psInfo == NULL || psInfo->hLayer == NULL) { - msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!", + msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!", "msOGRLayerNextShape()"); return(MS_FAILURE); } @@ -2470,7 +2029,7 @@ * OGR Support not included... * ------------------------------------------------------------------ */ - msSetError(MS_MISCERR, "OGR support is not available.", + msSetError(MS_MISCERR, "OGR support is not available.", "msOGRLayerGetShape()"); return(MS_FAILURE); @@ -2484,7 +2043,7 @@ * * Returns MS_SUCCESS/MS_FAILURE **********************************************************************/ -int msOGRLayerGetExtent(layerObj *layer, rectObj *extent) +int msOGRLayerGetExtent(layerObj *layer, rectObj *extent) { #ifdef USE_OGR msOGRFileInfo *psInfo =(msOGRFileInfo*)layer->layerinfo; @@ -2492,7 +2051,7 @@ if (psInfo == NULL || psInfo->hLayer == NULL) { - msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!", + msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!", "msOGRLayerGetExtent()"); return(MS_FAILURE); } @@ -2508,7 +2067,7 @@ if (OGR_L_GetExtent( psInfo->hLayer, &oExtent, TRUE) != OGRERR_NONE) { RELEASE_OGR_LOCK; - msSetError(MS_MISCERR, "Unable to get extents for this layer.", + msSetError(MS_MISCERR, "Unable to get extents for this layer.", "msOGRLayerGetExtent()"); return(MS_FAILURE); } @@ -2525,7 +2084,7 @@ * OGR Support not included... * ------------------------------------------------------------------ */ - msSetError(MS_MISCERR, "OGR support is not available.", + msSetError(MS_MISCERR, "OGR support is not available.", "msOGRLayerGetExtent()"); return(MS_FAILURE); @@ -2541,7 +2100,7 @@ * default symbol name, and if not found return 0. **********************************************************************/ #ifdef USE_OGR -static int msOGRGetSymbolId(symbolSetObj *symbolset, const char *pszSymbolId, +static int msOGRGetSymbolId(symbolSetObj *symbolset, const char *pszSymbolId, const char *pszDefaultSymbol) { // Symbol name mapping: @@ -2576,7 +2135,7 @@ * msOGRLayerGetAutoStyle() * * Fills a classObj with style info from the specified shape. - * For optimal results, this should be called immediately after + * For optimal results, this should be called immediately after * GetNextShape() or GetShape() so that the shape doesn't have to be read * twice. * @@ -2591,7 +2150,7 @@ if (psInfo == NULL || psInfo->hLayer == NULL) { - msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!", + msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!", "msOGRLayerGetAutoStyle()"); return(MS_FAILURE); } @@ -2601,7 +2160,7 @@ if( (psInfo->poCurTile == NULL || tile != psInfo->poCurTile->nTileId) && msOGRFileReadTile( layer, psInfo ) != MS_SUCCESS ) return MS_FAILURE; - + psInfo = psInfo->poCurTile; } @@ -2609,7 +2168,7 @@ * Read shape or reuse ref. to last shape read. * ------------------------------------------------------------------ */ ACQUIRE_OGR_LOCK; - if (psInfo->hLastFeature == NULL || + if (psInfo->hLastFeature == NULL || OGR_F_GetFID( psInfo->hLastFeature ) != record) { if (psInfo->hLastFeature) @@ -2669,7 +2228,7 @@ // The scale factor that OGR expect is the ground/paper scale // e.g. if 1 ground unit = 0.01 paper unit then scale=1/0.01=100 // cellsize if number of ground units/pixel, and OGR assumes that - // there is 72*39.37 pixels/ground units (since meter is assumed + // there is 72*39.37 pixels/ground units (since meter is assumed // for ground... but what ground units we have does not matter // as long as use the same assumptions everywhere) // That gives scale = cellsize*72*39.37 @@ -2687,16 +2246,16 @@ // Enclose the text string inside quotes to make sure it is seen // as a string by the parser inside loadExpression(). (bug185) - msLoadExpressionString(&(c->text), - (char*)CPLSPrintf("\"%s\"", - OGR_ST_GetParamStr(hLabelStyle, - OGRSTLabelTextString, + msLoadExpressionString(&(c->text), + (char*)CPLSPrintf("\"%s\"", + OGR_ST_GetParamStr(hLabelStyle, + OGRSTLabelTextString, &bIsNull))); - c->label.angle = OGR_ST_GetParamDbl(hLabelStyle, + c->label.angle = OGR_ST_GetParamDbl(hLabelStyle, OGRSTLabelAngle, &bIsNull); - c->label.size = OGR_ST_GetParamDbl(hLabelStyle, + c->label.size = OGR_ST_GetParamDbl(hLabelStyle, OGRSTLabelSize, &bIsNull); if( c->label.size < 1 ) /* no point dropping to zero size */ c->label.size = 1; @@ -2704,7 +2263,7 @@ // OGR default is anchor point = LL, so label is at UR of anchor c->label.position = MS_UR; - const char *pszColor = OGR_ST_GetParamStr(hLabelStyle, + const char *pszColor = OGR_ST_GetParamStr(hLabelStyle, OGRSTLabelFColor, &bIsNull); if (!bIsNull && OGR_ST_GetRGBFromString(hLabelStyle, pszColor, @@ -2713,7 +2272,7 @@ MS_INIT_COLOR(c->label.color, r, g, b); } - pszColor = OGR_ST_GetParamStr(hLabelStyle, + pszColor = OGR_ST_GetParamStr(hLabelStyle, OGRSTLabelBColor, &bIsNull); if (!bIsNull && OGR_ST_GetRGBFromString(hLabelStyle, pszColor, @@ -2722,7 +2281,7 @@ MS_INIT_COLOR(c->label.backgroundcolor, r, g, b); } - pszColor = OGR_ST_GetParamStr(hLabelStyle, + pszColor = OGR_ST_GetParamStr(hLabelStyle, OGRSTLabelHColor, &bIsNull); if (!bIsNull && OGR_ST_GetRGBFromString(hLabelStyle, pszColor, @@ -2732,7 +2291,7 @@ } #if GDAL_VERSION_NUM >= 1600 - pszColor = OGR_ST_GetParamStr(hLabelStyle, + pszColor = OGR_ST_GetParamStr(hLabelStyle, OGRSTLabelOColor, &bIsNull); if (!bIsNull && OGR_ST_GetRGBFromString(hLabelStyle, pszColor, @@ -2745,13 +2304,13 @@ // Label font... do our best to use TrueType fonts, otherwise // fallback on bitmap fonts. #if defined(USE_GD_TTF) || defined (USE_GD_FT) - const char *pszBold = OGR_ST_GetParamNum(hLabelStyle, - OGRSTLabelBold, + const char *pszBold = OGR_ST_GetParamNum(hLabelStyle, + OGRSTLabelBold, &bIsNull) ? "-bold" : ""; - const char *pszItalic = OGR_ST_GetParamNum(hLabelStyle, - OGRSTLabelItalic, + const char *pszItalic = OGR_ST_GetParamNum(hLabelStyle, + OGRSTLabelItalic, &bIsNull) ? "-italic" : ""; - const char *pszFontName = OGR_ST_GetParamStr(hLabelStyle, + const char *pszFontName = OGR_ST_GetParamStr(hLabelStyle, OGRSTLabelFontName, &bIsNull); const char *pszName = CPLSPrintf("%s%s%s", pszFontName, pszBold, pszItalic); @@ -2800,8 +2359,8 @@ // Enclose the text string inside quotes to make sure it is seen // as a string by the parser inside loadExpression(). (bug185) - msLoadExpressionString(&(c->text), - (char*)CPLSPrintf("\"%s\"", + msLoadExpressionString(&(c->text), + (char*)CPLSPrintf("\"%s\"", poLabelStyle->TextString(bIsNull))); c->label.angle = poLabelStyle->Angle(bIsNull); @@ -2884,8 +2443,8 @@ OGRStyleToolH hPenStyle = hStylePart; bIsPen = TRUE; - const char *pszPenName = OGR_ST_GetParamStr(hPenStyle, - OGRSTPenId, + const char *pszPenName = OGR_ST_GetParamStr(hPenStyle, + OGRSTPenId, &bIsNull); if (bIsNull) pszPenName = NULL; colorObj oPenColor; @@ -2903,7 +2462,7 @@ } else { - const char *pszColor = OGR_ST_GetParamStr(hPenStyle, + const char *pszColor = OGR_ST_GetParamStr(hPenStyle, OGRSTPenColor, &bIsNull); if (!bIsNull && OGR_ST_GetRGBFromString(hPenStyle, pszColor, @@ -2914,7 +2473,7 @@ msDebug("** PEN COLOR = %d %d %d **\n", r,g,b); } - nPenSize = OGR_ST_GetParamNum(hPenStyle, + nPenSize = OGR_ST_GetParamNum(hPenStyle, OGRSTPenWidth, &bIsNull); if (bIsNull) nPenSize = 1; @@ -2924,11 +2483,11 @@ // // First try to match pen name in symbol file // If not found then look for a "default-circle" symbol - // that we'll use for producing thick lines. - // Otherwise symbol will be set to 0 and line will + // that we'll use for producing thick lines. + // Otherwise symbol will be set to 0 and line will // be 1 pixel wide. nPenSymbol = msOGRGetSymbolId(&(map->symbolset), - pszPenName, + pszPenName, (nPenSize>1)?"default-circle":NULL); } } @@ -2937,7 +2496,7 @@ if (bIsBrush || layer->type == MS_LAYER_POLYGON) { // This is a multipart symbology, so pen defn goes in the - // overlaysymbol params + // overlaysymbol params if (msMaybeAllocateStyle(c, 1)) { RELEASE_OGR_LOCK; @@ -2958,7 +2517,7 @@ } if(layer->type == MS_LAYER_POLYGON) - c->styles[0]->outlinecolor = c->styles[0]->color = + c->styles[0]->outlinecolor = c->styles[0]->color = oPenColor; else c->styles[0]->color = oPenColor; @@ -3006,11 +2565,11 @@ // // First try to match pen name in symbol file // If not found then look for a "default-circle" symbol - // that we'll use for producing thick lines. - // Otherwise symbol will be set to 0 and line will + // that we'll use for producing thick lines. + // Otherwise symbol will be set to 0 and line will // be 1 pixel wide. nPenSymbol = msOGRGetSymbolId(&(map->symbolset), - pszPenName, + pszPenName, (nPenSize>1)?"default-circle":NULL); } } @@ -3019,7 +2578,7 @@ if (bIsBrush || layer->type == MS_LAYER_POLYGON) { // This is a multipart symbology, so pen defn goes in the - // overlaysymbol params + // overlaysymbol params if (msMaybeAllocateStyle(c, 1)) { RELEASE_OGR_LOCK; @@ -3040,7 +2599,7 @@ } if(layer->type == MS_LAYER_POLYGON) - c->styles[0]->outlinecolor = c->styles[0]->color = + c->styles[0]->outlinecolor = c->styles[0]->color = oPenColor; else c->styles[0]->color = oPenColor; @@ -3055,8 +2614,8 @@ { OGRStyleToolH hBrushStyle = hStylePart; - const char *pszBrushName = OGR_ST_GetParamStr(hBrushStyle, - OGRSTBrushId, + const char *pszBrushName = OGR_ST_GetParamStr(hBrushStyle, + OGRSTBrushId, &bIsNull); if (bIsNull) pszBrushName = NULL; @@ -3076,10 +2635,10 @@ else { bIsBrush = TRUE; - const char *pszColor = OGR_ST_GetParamStr(hBrushStyle, + const char *pszColor = OGR_ST_GetParamStr(hBrushStyle, OGRSTBrushFColor, &bIsNull); - if (!bIsNull && OGR_ST_GetRGBFromString(hBrushStyle, + if (!bIsNull && OGR_ST_GetRGBFromString(hBrushStyle, pszColor, &r, &g, &b, &t)) { @@ -3088,9 +2647,9 @@ msDebug("** BRUSH COLOR = %d %d %d **\n", r,g,b); } - pszColor = OGR_ST_GetParamStr(hBrushStyle, + pszColor = OGR_ST_GetParamStr(hBrushStyle, OGRSTBrushBColor, &bIsNull); - if (!bIsNull && OGR_ST_GetRGBFromString(hBrushStyle, + if (!bIsNull && OGR_ST_GetRGBFromString(hBrushStyle, pszColor, &r, &g, &b, &t)) { @@ -3099,13 +2658,13 @@ // Symbol name mapping: // First look for the native symbol name, then the ogr-... - // generic name. + // generic name. // If none provided or found then use 0: solid fill - - const char *pszName = OGR_ST_GetParamStr(hBrushStyle, - OGRSTBrushId, + + const char *pszName = OGR_ST_GetParamStr(hBrushStyle, + OGRSTBrushId, &bIsNull); - c->styles[0]->symbol = msOGRGetSymbolId(&(map->symbolset), + c->styles[0]->symbol = msOGRGetSymbolId(&(map->symbolset), pszName, NULL); } } @@ -3148,13 +2707,13 @@ // Symbol name mapping: // First look for the native symbol name, then the ogr-... - // generic name. + // generic name. // If none provided or found then use 0: solid fill - + const char *pszName = poBrushStyle->Id(bIsNull); if (bIsNull) pszName = NULL; - c->styles[0]->symbol = msOGRGetSymbolId(&(map->symbolset), + c->styles[0]->symbol = msOGRGetSymbolId(&(map->symbolset), pszName, NULL); } } @@ -3171,17 +2730,17 @@ return(MS_FAILURE); } - const char *pszColor = OGR_ST_GetParamStr(hSymbolStyle, + const char *pszColor = OGR_ST_GetParamStr(hSymbolStyle, OGRSTSymbolColor, &bIsNull); - if (!bIsNull && OGR_ST_GetRGBFromString(hSymbolStyle, + if (!bIsNull && OGR_ST_GetRGBFromString(hSymbolStyle, pszColor, &r, &g, &b, &t)) { MS_INIT_COLOR(c->styles[0]->color, r, g, b); } -#if GDAL_VERSION_NUM >= 1600 +#if GDAL_VERSION_NUM >= 1600 pszColor = OGR_ST_GetParamStr(hSymbolStyle, OGRSTSymbolOColor, &bIsNull); @@ -3195,23 +2754,23 @@ c->styles[0]->angle = OGR_ST_GetParamNum(hSymbolStyle, OGRSTSymbolAngle, &bIsNull); - - c->styles[0]->size = OGR_ST_GetParamNum(hSymbolStyle, - OGRSTSymbolSize, + + c->styles[0]->size = OGR_ST_GetParamNum(hSymbolStyle, + OGRSTSymbolSize, &bIsNull); // Symbol name mapping: // First look for the native symbol name, then the ogr-... // generic name, and in last resort try "default-marker" if // provided by user. - const char *pszName = OGR_ST_GetParamStr(hSymbolStyle, - OGRSTSymbolId, + const char *pszName = OGR_ST_GetParamStr(hSymbolStyle, + OGRSTSymbolId, &bIsNull); if (bIsNull) pszName = NULL; c->styles[0]->symbol = msOGRGetSymbolId(&(map->symbolset), - pszName, + pszName, "default-marker"); } #else /* OGR Style C++ */ @@ -3232,7 +2791,7 @@ } c->styles[0]->angle = poSymbolStyle->Angle(bIsNull); - + c->styles[0]->size = (int)poSymbolStyle->Size(bIsNull); // Symbol name mapping: @@ -3244,7 +2803,7 @@ pszName = NULL; c->styles[0]->symbol = msOGRGetSymbolId(&(map->symbolset), - pszName, + pszName, "default-marker"); } #endif /* OGRStyle C API */ @@ -3272,7 +2831,7 @@ * OGR Support not included... * ------------------------------------------------------------------ */ - msSetError(MS_MISCERR, "OGR support is not available.", + msSetError(MS_MISCERR, "OGR support is not available.", "msOGRLayerGetAutoStyle()"); return(MS_FAILURE); @@ -3324,7 +2883,7 @@ /* layer->vtable->LayerCloseConnection, use default */ layer->vtable->LayerApplyFilterToLayer = msLayerApplyCondSQLFilterToLayer; - + layer->vtable->LayerSetTimeFilter = msLayerMakeBackticsTimeFilter; /* layer->vtable->LayerCreateItems, use default */ /* layer->vtable->LayerGetNumFeatures, use default */ @@ -3341,14 +2900,14 @@ #ifdef USE_OGR OGRGeometryH hGeom = NULL; shapeObj *shape=NULL; - - if(!string) + + if(!string) return NULL; - + ACQUIRE_OLD_OGR_LOCK; if( OGR_G_CreateFromWkt( (char **)&string, NULL, &hGeom ) != OGRERR_NONE ) { - msSetError(MS_OGRERR, "Failed to parse WKT string.", + msSetError(MS_OGRERR, "Failed to parse WKT string.", "msOGRShapeFromWKT()" ); RELEASE_OLD_OGR_LOCK; return NULL; @@ -3360,8 +2919,8 @@ msInitShape(shape); /* translate WKT into an OGRGeometry. */ - - if( msOGRGeometryToShape( hGeom, shape, + + if( msOGRGeometryToShape( hGeom, shape, wkbFlatten(OGR_G_GetGeometryType(hGeom)) ) == MS_FAILURE ) { @@ -3390,7 +2949,7 @@ int i; char *wkt = NULL; - if(!shape) + if(!shape) return NULL; ACQUIRE_OLD_OGR_LOCK; @@ -3399,32 +2958,32 @@ { hGeom = OGR_G_CreateGeometry( wkbPoint ); #if GDAL_VERSION_NUM >= 1310 - OGR_G_SetPoint_2D( hGeom, 0, - shape->line[0].point[0].x, + OGR_G_SetPoint_2D( hGeom, 0, + shape->line[0].point[0].x, shape->line[0].point[0].y ); #else - OGR_G_SetPoint( hGeom, 0, - shape->line[0].point[0].x, + OGR_G_SetPoint( hGeom, 0, + shape->line[0].point[0].x, shape->line[0].point[0].y, 0.0 ); #endif } - else if( shape->type == MS_SHAPE_POINT && shape->numlines == 1 + else if( shape->type == MS_SHAPE_POINT && shape->numlines == 1 && shape->line[0].numpoints > 1 ) { hGeom = OGR_G_CreateGeometry( wkbMultiPoint ); for( i = 0; i < shape->line[0].numpoints; i++ ) { OGRGeometryH hPoint; - + hPoint = OGR_G_CreateGeometry( wkbPoint ); #if GDAL_VERSION_NUM >= 1310 - OGR_G_SetPoint_2D( hPoint, 0, - shape->line[0].point[i].x, + OGR_G_SetPoint_2D( hPoint, 0, + shape->line[0].point[i].x, shape->line[0].point[i].y ); #else - OGR_G_SetPoint( hPoint, 0, - shape->line[0].point[i].x, + OGR_G_SetPoint( hPoint, 0, + shape->line[0].point[i].x, shape->line[0].point[i].y, 0.0 ); #endif @@ -3437,12 +2996,12 @@ for( i = 0; i < shape->line[0].numpoints; i++ ) { #if GDAL_VERSION_NUM >= 1310 - OGR_G_AddPoint_2D( hGeom, - shape->line[0].point[i].x, + OGR_G_AddPoint_2D( hGeom, + shape->line[0].point[i].x, shape->line[0].point[i].y ); #else - OGR_G_AddPoint( hGeom, - shape->line[0].point[i].x, + OGR_G_AddPoint( hGeom, + shape->line[0].point[i].x, shape->line[0].point[i].y, 0.0 ); #endif @@ -3459,12 +3018,12 @@ for( i = 0; i < shape->line[iLine].numpoints; i++ ) { #if GDAL_VERSION_NUM >= 1310 - OGR_G_AddPoint_2D( hGeom, - shape->line[iLine].point[i].x, + OGR_G_AddPoint_2D( hGeom, + shape->line[iLine].point[i].x, shape->line[iLine].point[i].y ); #else - OGR_G_AddPoint( hGeom, - shape->line[iLine].point[i].x, + OGR_G_AddPoint( hGeom, + shape->line[iLine].point[i].x, shape->line[iLine].point[i].y, 0.0 ); #endif @@ -3485,17 +3044,17 @@ { OGRGeometryH hRing; hRing = OGR_G_CreateGeometry( wkbLinearRing ); - + for( i = 0; i < shape->line[iLine].numpoints; i++ ) { #if GDAL_VERSION_NUM >= 1310 - OGR_G_AddPoint_2D( hRing, - shape->line[iLine].point[i].x, + OGR_G_AddPoint_2D( hRing, + shape->line[iLine].point[i].x, shape->line[iLine].point[i].y ); #else - OGR_G_AddPoint( hRing, - shape->line[iLine].point[i].x, - shape->line[iLine].point[i].y, + OGR_G_AddPoint( hRing, + shape->line[iLine].point[i].x, + shape->line[iLine].point[i].y, 0.0 ); #endif }