Skip to content

Commit

Permalink
add a static table to define axis order for some epsg codes (#3582)
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/mapserver/trunk@11155 7532c77e-422f-0410-93f4-f0b67bdd69e2
  • Loading branch information
Assefa Yewondwossen committed Mar 11, 2011
1 parent 7d1d0ba commit 4ffda83
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 1 deletion.
2 changes: 2 additions & 0 deletions HISTORY.TXT
Expand Up @@ -14,6 +14,8 @@ For a complete change history, please see the Subversion log comments.
Current Version (SVN trunk):
----------------------------

- Add a static table to define the axis order for soem epsg codes (/3582)

- Add possibility to use KML_NAME_ITEM (#3728)

- Fixed mapfile parsing error when a label angle referenced an attribute
Expand Down
8 changes: 8 additions & 0 deletions mapaxisorder.csv
@@ -0,0 +1,8 @@
epsg_code,inverted
3034,1
3035,1
3042,1
3043,1
4326,1
4559,1
4471,0
56 changes: 56 additions & 0 deletions mapaxisorder.h
@@ -0,0 +1,56 @@
/******************************************************************************
* $Id: $
*
* Project: MapServer
* Purpose: Axis lookup table
*
******************************************************************************
* Copyright (c) 1996-2005 Regents of the University of Minnesota.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* 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
* 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
* DEALINGS IN THE SOFTWARE.
****************************************************************************/

/*
* Generated file
*
* This file was generated from by means of a script. Do not edit manually.
*/

#ifdef __cplusplus
extern "C" {
#endif

static struct axisOrientationEpsgCodes_s {
int code;
int inverted; /*true=1, false =0*/
} axisOrientationEpsgCodes[] = {
{3034,1},
{3035,1},
{3042,1},
{3043,1},
{4326,1},
{4559,1},
{4471,0},
};

#define AXIS_ORIENTATION_TABLE_SIZE 8

#ifdef __cplusplus
}
#endif
87 changes: 87 additions & 0 deletions mapaxisorder.sh
@@ -0,0 +1,87 @@
#!/bin/bash
INFILE="./mapaxisorder.csv"
OUTFILE="./mapaxisorder.h"

# create array of elements from $INFILE
unset ARRAY i
while read -r LINE; do ARRAY[i++]=$LINE; done < $INFILE

print_header ()
{

echo '/******************************************************************************'
echo ' * $Id: $'
echo ' *'
echo ' * Project: MapServer'
echo ' * Purpose: Axis lookup table'
echo ' *'
echo ' ******************************************************************************'
echo ' * Copyright (c) 1996-2005 Regents of the University of Minnesota.'
echo ' *'
echo ' * Permission is hereby granted, free of charge, to any person obtaining a'
echo ' * copy of this software and associated documentation files (the "Software"),'
echo ' * to deal in the Software without restriction, including without limitation'
echo ' * the rights to use, copy, modify, merge, publish, distribute, sublicense,'
echo ' * and/or sell copies of the Software, and to permit persons to whom the'
echo ' * Software is furnished to do so, subject to the following conditions:'
echo ' *'
echo ' * The above copyright notice and this permission notice shall be included in '
echo ' * all copies of this Software or works derived from this Software.'
echo ' *'
echo ' * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS'
echo ' * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,'
echo ' * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL'
echo ' * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER'
echo ' * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING'
echo ' * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER'
echo ' * DEALINGS IN THE SOFTWARE.'
echo ' ****************************************************************************/'

}

print_comment ()
{
echo ' '
echo '/*'
echo ' * Generated file'
echo ' *'
echo ' * This file was generated from by means of a script. Do not edit manually.'
echo ' */'
echo ' '

}

print_body ()
{

echo '#ifdef __cplusplus'
echo 'extern "C" '{
echo '#endif'
echo ' '
echo 'static struct axisOrientationEpsgCodes_s {'
echo ' int code;'
echo ' int inverted; /*true=1, false =0*/'
echo '} axisOrientationEpsgCodes[] = {'

# unset first array element
unset ARRAY[0]
# traverse array and print out elements
for x in "${ARRAY[@]}"; do
echo " {${x}},"
done

echo '};'
echo ' '
echo '#define AXIS_ORIENTATION_TABLE_SIZE 8'
echo ' '
echo '#ifdef __cplusplus'
echo '}'
echo '#endif'

}

print_header > ./$OUTFILE
print_comment >> ./$OUTFILE
print_body >> ./$OUTFILE

exit 0
27 changes: 26 additions & 1 deletion mapfile.c
Expand Up @@ -37,6 +37,7 @@
#include "mapfile.h"
#include "mapthread.h"
#include "maptime.h"
#include "mapaxisorder.h"

#ifdef USE_GDAL
# include "cpl_conv.h"
Expand Down Expand Up @@ -66,6 +67,29 @@ static int loadGrid( layerObj *pLayer );
static int loadStyle(styleObj *style);
static void writeStyle(FILE* stream, int indent, styleObj *style);
static int msResolveSymbolNames(mapObj *map);


/************************************************************************/
/* int msIsAxisInverted */
/* check to see if we shoudl invert the axis. */
/* */
/************************************************************************/
static int msIsAxisInverted(int epsg_code)
{
int i;
/*check first in the static table*/
for (i=0; i<AXIS_ORIENTATION_TABLE_SIZE; i++)
{
if (axisOrientationEpsgCodes[i].code == epsg_code)
return axisOrientationEpsgCodes[i].inverted;
}
if ( epsg_code >=4000 && epsg_code < 5000)
return MS_TRUE;

return MS_FALSE;

}

/*
** Symbol to string static arrays needed for writing map files.
** Must be kept in sync with enumerations and defines found in mapserver.h.
Expand Down Expand Up @@ -1258,8 +1282,9 @@ int msLoadProjectionStringEPSG(projectionObj *p, const char *value)
p->args = (char**)msSmallMalloc(sizeof(char*) * 2);
p->args[0] = init_string;
p->numargs = 1;


if( atoi(value+5) >= 4000 && atoi(value+5) < 5000 )
if( msIsAxisInverted(atoi(value+5)))
{
p->args[1] = msStrdup("+epsgaxis=ne");
p->numargs = 2;
Expand Down

0 comments on commit 4ffda83

Please sign in to comment.