| 210 | /************************************************************************/ |
| 211 | |
| 212 | static int msOGRWriteShape( layerObj *map_layer, OGRLayerH hOGRLayer, |
| 213 | shapeObj *shape, gmlItemListObj *item_list ) |
| 214 | |
| 215 | { |
| 216 | OGRGeometryH hGeom = NULL; |
| 217 | OGRFeatureH hFeat; |
| 218 | OGRErr eErr; |
| 219 | int i, out_field; |
| 220 | OGRwkbGeometryType eLayerGType, eFeatureGType = wkbUnknown; |
| 221 | |
| 222 | /* -------------------------------------------------------------------- */ |
| 223 | /* Transform point geometry. */ |
| 224 | /* -------------------------------------------------------------------- */ |
| 225 | if( shape->type == MS_SHAPE_POINT ) |
| 226 | { |
| 227 | if( shape->numlines != 1 || shape->line[0].numpoints != 1 ) |
| 228 | { |
| 229 | msSetError(MS_MISCERR, |
| 230 | "Failed on odd point geometry.", |
| 231 | "msOGRWriteShape()"); |
| 232 | return MS_FAILURE; |
| 233 | } |
| 234 | |
| 235 | hGeom = OGR_G_CreateGeometry( wkbPoint ); |
| 236 | OGR_G_SetPoint( hGeom, 0, |
| 237 | shape->line[0].point[0].x, |
| 238 | shape->line[0].point[0].y, |
| 239 | 0.0 ); |
| 240 | } |
| 241 | |
| 242 | /* -------------------------------------------------------------------- */ |
| 243 | /* Transform line geometry. */ |
| 244 | /* -------------------------------------------------------------------- */ |
| 245 | else if( shape->type == MS_SHAPE_LINE ) |
| 246 | { |
| 247 | OGRGeometryH hML = NULL; |
| 248 | int j; |
| 249 | |
| 250 | if( shape->numlines < 1 || shape->line[0].numpoints < 2 ) |
| 251 | { |
| 252 | msSetError(MS_MISCERR, |
| 253 | "Failed on odd line geometry.", |
| 254 | "msOGRWriteShape()"); |
| 255 | return MS_FAILURE; |
| 256 | } |
| 257 | |
| 258 | if( shape->numlines > 1 ) |
| 259 | hML = OGR_G_CreateGeometry( wkbMultiLineString ); |
| 260 | |
| 261 | for( j = 0; j < shape->numlines; j++ ) |
| 262 | { |
| 263 | hGeom = OGR_G_CreateGeometry( wkbLineString ); |
| 264 | |
| 265 | for( i = 0; i < shape->line[j].numpoints; i++ ) |
| 266 | { |
| 267 | OGR_G_SetPoint( hGeom, i, |
| 268 | shape->line[j].point[i].x, |
| 269 | shape->line[j].point[i].y, |
no test coverage detected