| 537 | } |
| 538 | |
| 539 | int KmlRenderer::checkProjection(mapObj *map) |
| 540 | { |
| 541 | projectionObj *projection= &map->projection; |
| 542 | #ifdef USE_PROJ |
| 543 | if (projection && projection->numargs > 0 && pj_is_latlong(projection->proj)) |
| 544 | { |
| 545 | return MS_SUCCESS; |
| 546 | } |
| 547 | else |
| 548 | { |
| 549 | char epsg_string[100]; |
| 550 | rectObj sRect; |
| 551 | projectionObj out; |
| 552 | |
| 553 | /* for layer the do not have any projection set, set them with the current map |
| 554 | projection*/ |
| 555 | if (projection && projection->numargs > 0) |
| 556 | { |
| 557 | layerObj *lp = NULL; |
| 558 | int i =0; |
| 559 | char *pszMapProjectString = msGetProjectionString(projection); |
| 560 | if (pszMapProjectString) |
| 561 | { |
| 562 | for(i=0; i<map->numlayers; i++) |
| 563 | { |
| 564 | lp = GET_LAYER(map, i); |
| 565 | if (lp->projection.numargs == 0 && lp->transform == MS_TRUE) |
| 566 | { |
| 567 | msFreeProjection(&lp->projection); |
| 568 | msLoadProjectionString(&lp->projection, pszMapProjectString); |
| 569 | } |
| 570 | } |
| 571 | msFree(pszMapProjectString); |
| 572 | } |
| 573 | } |
| 574 | strcpy(epsg_string, "epsg:4326" ); |
| 575 | msInitProjection(&out); |
| 576 | msLoadProjectionString(&out, epsg_string); |
| 577 | |
| 578 | sRect = map->extent; |
| 579 | msProjectRect(projection, &out, &sRect); |
| 580 | msFreeProjection(projection); |
| 581 | msLoadProjectionString(projection, epsg_string); |
| 582 | |
| 583 | /*change also units and extents*/ |
| 584 | map->extent = sRect; |
| 585 | map->units = MS_DD; |
| 586 | |
| 587 | |
| 588 | if (map->debug) |
| 589 | msDebug("KmlRenderer::checkProjection: Mapfile projection set to epsg:4326\n"); |
| 590 | |
| 591 | return MS_SUCCESS; |
| 592 | } |
| 593 | |
| 594 | #else |
| 595 | msSetError(MS_MISCERR, "Projection support not enabled", "KmlRenderer::checkProjection" ); |
| 596 | return MS_FAILURE; |
nothing calls this directly
no test coverage detected