Ticket #2346 (closed enhancement: fixed)

Opened 1 year ago

Last modified 8 months ago

Purpose for new API functions: getMapCenter and setMapCenter

Reported by: Zhonghai Assigned to: tamas
Priority: high Milestone: 5.2 release
Component: MapServer C Library Version: svn-trunk (development)
Severity: normal Keywords: getMapCenter and setMapCenter
Cc:

Description

Hi All,

I've today discussed with Tamas about adding two new handy functions into MapScript? API, especially for .NET C#. These two functions are:

1. The getMapCenter function is associated with the mapObj, function signitures should look like:

    ''' <summary>
    ''' Gets the map center point of the current mapObj.
    ''' </summary>
    ''' <returns>The center point of the current mapObj</returns>
    ''' <remarks>This function should be associated directly with the mapObj.
    ''' If the function is called, the center point of type pointObj should be
    ''' returned, whose coordinates are specified in the mapObj output
    ''' Projection coordinate system.</remarks>
    Public Function getMapCenter() As pointObj

    End Function

2. The setMapCenter function is also associated with the mapObj, it receives a integer zoom factor for zoom and a pointObj as the new map center. The funciton signitures should look like:

    ''' <summary>
    ''' Sets the new map center for the current mapObj.
    ''' </summary>
    ''' <param name="zoomFactor">The zoom factor value</param>
    ''' <param name="centerPoint">^The new map center point</param>
    ''' <remarks>This function should be directly associated with the mapObj.
    ''' If the function is called, the mapObj should be set to the new map
    ''' center specified by the center point parameter of type pointObj.
    ''' The zoom factor value is used for zooming if necessary, a default
    ''' value should be 1, which indicates no zooming effects.</remarks>
    Public Sub setMapCenter(ByVal zoomFactor As Integer, ByVal centerPoint As pointObj)

    End Sub

like Tamas said, those two functions can actually be coded with the current APIs, but if we have them directly for mapObj, it should be very handy. MapServer has many good stuffs, but we can always make it better.

For the getMapCenter function, if it returns a pointObj, we can directly get the coordinates of this point, and even more, all the functions and properties of pointObj will be available for use.

I strongly suggest those two functions to be implemented for the next update.

Best Regards

Zhonghai Wang

Change History

(in reply to: ↑ description ) 10/08/07 11:08:33 changed by Zhonghai

  • priority changed from normal to high.
  • keywords set to getMapCenter and setMapCenter.
  • version changed from unspecified to svn-trunk (development).
  • type changed from defect to enhancement.
  • milestone set to 5.0.1 release.

Replying to Zhonghai:

Hi All, I've today discussed with Tamas about adding two new handy functions into MapScript? API, especially for .NET C#. These two functions are: 1. The getMapCenter function is associated with the mapObj, function signitures should look like: {{{ <summary> Gets the map center point of the current mapObj. </summary> <returns>The center point of the current mapObj</returns> <remarks>This function should be associated directly with the mapObj. If the function is called, the center point of type pointObj should be returned, whose coordinates are specified in the mapObj output Projection coordinate system.</remarks> Public Function getMapCenter() As pointObj End Function }}} 2. The setMapCenter function is also associated with the mapObj, it receives a integer zoom factor for zoom and a pointObj as the new map center. The funciton signitures should look like: {{{ <summary> Sets the new map center for the current mapObj. </summary> <param name="zoomFactor">The zoom factor value</param> <param name="centerPoint">The new map center point</param> <remarks>This function should be directly associated with the mapObj. If the function is called, the mapObj should be set to the new map center specified by the center point parameter of type pointObj. The zoom factor value is used for zooming if necessary, a default value should be 1, which indicates no zooming effects.</remarks> Public Sub setMapCenter(ByVal? zoomFactor As Integer, ByVal? centerPoint As pointObj) End Sub }}} like Tamas said, those two functions can actually be coded with the current APIs, but if we have them directly for mapObj, it should be very handy. MapServer has many good stuffs, but we can always make it better. For the getMapCenter function, if it returns a pointObj, we can directly get the coordinates of this point, and even more, all the functions and properties of pointObj will be available for use. I strongly suggest those two functions to be implemented for the next update. Best Regards Zhonghai Wang

10/08/07 11:52:12 changed by tamas

  • owner changed from sdlime to tamas.

01/05/08 11:15:52 changed by tamas

  • status changed from new to assigned.

I've implemented the following mapscript functions:

mapObj.offsetExtent( float x, float y) : int

Offset the map extent based on the given distances in map coordinates, returns MS_SUCCESS or MS_FAILURE.

mapObj.scaleExtent( float zoomfactor, float minscaledenom, float maxscaledenom) : int

Scale the map extent using the zoomfactor and ensure the extent within the minscaledenom and maxscaledenom domain. If minscaledenom and/or maxscaledenom is 0 then the parameter is not taken into account. returns MS_SUCCESS or MS_FAILURE.

mapObj.setCenter( pointObj_ center ) : int

Set the map center to the given map point, returns MS_SUCCESS or MS_FAILURE.

rectObj.getCenter() : pointObj_

Return the center point of the rectagle.

These functions should cover the requirements of this ticket.

To retrieve the center of the map one can use: pointObj center = map.extent.getCenter();

To set the map center and scale by 1.2: map.setCenter(center); map.scaleExtent(1.2, 0, 0);

We can limit the scale in between a given minscaledenom and maxscaledenom parameter.

To zoom to a specific scale we can use: map.scaleExtent(1.0, scaledenom, scaledenom);

01/05/08 11:17:02 changed by tamas

Committed in trunk r7244 and branch-5-0 r7245

And updated the mapscript.txt doc file.

01/05/08 11:17:14 changed by tamas

  • status changed from assigned to closed.
  • resolution set to fixed.

01/07/08 10:47:12 changed by tamas

  • milestone changed from 5.0.1 release to 5.2 release.

01/07/08 10:48:07 changed by tamas

reverted from 5.0 r7249

01/08/08 03:38:27 changed by Zhonghai

Great, thanks for all the efforts. I am looking forward to testing these new functions.

Zhonghai