Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#2346 closed enhancement (fixed)

Purpose for new API functions: getMapCenter and setMapCenter

Reported by: Zhonghai Owned by: 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
  1. 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 (8)

in reply to:  description comment:1 by Zhonghai, 16 years ago

Keywords: getMapCenter and setMapCenter added
Milestone: 5.0.1 release
Priority: normalhigh
Type: defectenhancement
Version: unspecifiedsvn-trunk (development)

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
  1. 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

comment:2 by tamas, 16 years ago

Owner: changed from sdlime to tamas

comment:3 by tamas, 16 years ago

Status: newassigned

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);

comment:4 by tamas, 16 years ago

Committed in trunk r7244 and branch-5-0 r7245

And updated the mapscript.txt doc file.

comment:5 by tamas, 16 years ago

Resolution: fixed
Status: assignedclosed

comment:6 by tamas, 16 years ago

Milestone: 5.0.1 release5.2 release

comment:7 by tamas, 16 years ago

reverted from 5.0 r7249

comment:8 by Zhonghai, 16 years ago

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

Zhonghai

Note: See TracTickets for help on using tickets.