Opened 15 years ago

Last modified 14 years ago

#3101 new enhancement

GRID : get the intersection points and labels

Reported by: assefa Owned by: assefa
Priority: normal Milestone: 6.0 release
Component: MapServer C Library Version: unspecified
Severity: normal Keywords: grid, graticule
Cc: sdlime, dmorissette, bfraser@…

Description

right now, MapServer can generate a graticule with labels using A GRID layer. Some times (most of the times??), when maps are printed, the grid labels are displayed outside the map area. The idea here is to have mapscript function that can be called on a grid layer that would provide a series of intersection coordinates (pixel) and labels, for the 4 side of this map. This would allow to use MapServer/mapscript with other tools such as fpdf to do a custom map composition. PDF is attached as an example of what could be done:

  • the map/grid image is generated using MapServer
  • the labels are extarcted from the grid layer as a series of labels and intersection positions
  • combination of the map and the labels is done using fpdf

Attachments (2)

gmap.png (139.7 KB ) - added by assefa 15 years ago.
example of usage
bug3101.png (142.3 KB ) - added by assefa 15 years ago.

Download all attachments as: .zip

Change History (9)

by assefa, 15 years ago

Attachment: gmap.png added

example of usage

comment:1 by assefa, 15 years ago

Cc: sdlime dmorissette added

the idea is to gave a layer level mapscript function (eg: getgridintersectioncoordinates) that would return an array with the labels and intersections positions.

in mapgraticule.c, we will add a function that would use the same exiting logic to return the labels and coordinates.

comment:2 by assefa, 15 years ago

Cc: bfraser@… added

An array for containing labels and pixel position for each side of the map can be retrieved using mapscript. Here is an example working locally:

$gridPositions = $gridLayer->getGridIntersectionCoordinates(); print_r($gridPositions);

toplabels: are the labels as defined on the grid layer toppoints: are the pixel positions of the labels

Array (

[topnumpoints] => 8 [toplabels] => Array

(

[0] => -104 [1] => -103 [2] => -102 [3] => -101 [4] => -100 [5] => -99 [6] => -98 [7] => -97

)

[toppoints] => Array

(

[0] => 58.644771782686 [1] => 0 [2] => 131.6280852226 [3] => 0 [4] => 204.61139866251 [5] => 0 [6] => 277.59471210243 [7] => 0 [8] => 350.57802554234 [9] => 0 [10] => 423.56133898225 [11] => 0 [12] => 496.54465242217 [13] => 0 [14] => 569.52796586208 [15] => 0

)

[bottomnumpoints] => 8 [bottomlabels] => Array

(

[0] => -104 [1] => -103 [2] => -102 [3] => -101 [4] => -100 [5] => -99 [6] => -98 [7] => -97

)

[bottompoints] => Array

(

[0] => 58.644771782686 [1] => 400 [2] => 131.6280852226 [3] => 400 [4] => 204.61139866251 [5] => 400 [6] => 277.59471210243 [7] => 400 [8] => 350.57802554234 [9] => 400 [10] => 423.56133898225 [11] => 400 [12] => 496.54465242217 [13] => 400 [14] => 569.52796586208 [15] => 400

)

[leftnumpoints] => 7 [leftlabels] => Array

(

[0] => 48.5 [1] => 49 [2] => 49.5 [3] => 50 [4] => 50.5 [5] => 51 [6] => 51.5

)

[leftpoints] => Array

(

[0] => 0 [1] => 384.93272574894 [2] => 0 [3] => 329.58684685042 [4] => 0 [5] => 273.68253549977 [6] => 0 [7] => 217.20406262141 [8] => 0 [9] => 160.13512061589 [10] => 0 [11] => 102.4587935912 [12] => 0 [13] => 44.157525677904

)

[rightnumpoints] => 7 [rightlabels] => Array

(

[0] => 48.5 [1] => 49 [2] => 49.5 [3] => 50 [4] => 50.5 [5] => 51 [6] => 51.5

)

[rightpoints] => Array

(

[0] => 600 [1] => 384.93272574894 [2] => 600 [3] => 329.58684685042 [4] => 600 [5] => 273.68253549977 [6] => 600 [7] => 217.20406262141 [8] => 600 [9] => 160.13512061589 [10] => 600 [11] => 102.4587935912 [12] => 600 [13] => 44.157525677904

)

)

In my case, I use mapserver to draw the map with the grid on it and get the grid positions and fpdf to do the composition (placing the map and the labels).

Attached is the resulting PDF.

by assefa, 15 years ago

Attachment: bug3101.png added

comment:3 by assefa, 15 years ago

committed in r9316. intersection coordinates can be retrieved for through php mapscript.

comment:4 by sdlime, 15 years ago

Will swig mapscript also be able to do this?

Steve

comment:5 by assefa, 15 years ago

I will add the swig and update doc

in reply to:  3 comment:6 by tomkralidis, 15 years ago

Replying to assefa:

committed in r9316. intersection coordinates can be retrieved for through php mapscript.

Assefa: I get the following warnings when building on fc11:

mapgraticule.c: In function 'msGraticuleLayerGetIntersectionPoints':
mapgraticule.c:630: warning: unused variable 'pszTmpText'
mapgraticule.c:626: warning: unused variable 'bHori'
mapgraticule.c:622: warning: unused variable 'retcode'
mapgraticule.c: At top level:
php_mapscript.c: In function 'php3_ms_lyr_getGridIntersectionCoordinates':
php_mapscript.c:8972: warning: unused variable 'tmp_arr'

comment:7 by assefa, 14 years ago

Milestone: 5.6 release6.0 release
Note: See TracTickets for help on using tickets.