Personal tools
You are here: Home Documentation Developer Documentation map_scale information
Document Actions

map_scale information

by callahan — last modified 2007-08-19 12:27

Accessing nformation that allows javascript code to convert from image pixel coordinates to world coordinates.

Overview

The LAS product server is typically used to generate images.  Along with those images, various other files are saved in the output/ directory including -- if the operations requests it -- information describing the relationship between pixels on the image and the real world coordinates they represent.  This information is stored in an xml file in the output/ directory as 'unique_ID_map_scale'.

This information is particularly useful to client pages that use javascript to create clickable or rubber-bandable maps from the LAS images.

Requesting map_scale results in operationsV7.xml

In order to take advantage of this capability, each operation that wishes to access the ~_map_scale response must request that it be generated by listing it in the <response ...> section of the definition of the operation in operationsV7.xml.  Here is an example:

<operation name="Color plot" ID="Plot_2D_XY" output_template="output" service_action="Plot_2D_XY" order="0100">
<service>ferret</service>
<response ID="PlotResp">
<result type="image" ID="plot_image" streamable="true" mime_type="image/png" file_suffix=".gif" />
<result type="ps" ID="plot_postscript" streamable="true" mime_type="application/postscript" file_suffix=".ps"/>
<result type="image" ID="ref_map" file_suffix=".gif" />
<result type="map_scale" ID="map_scale" file_suffix=".xml"/>
<result type="debug" ID="debug" file_suffix=".txt"/>
<result type="cancel" ID="cancel" file_suffix=".txt"/>
</response>
<region>
<intervals name="xy" />
</region>
<grid_types>
<grid_type name="regular" />
</grid_types>
<optiondef IDREF="Options_2D_image_contour_xy"/>
</operation>

The map_scale.xml file

When LAS prforms an operation that requests a map_scale result a file similar to the following will be found in the output/ directory:

<?xml version="1.0" encoding="UTF-8"?>
<map_scale>
<x_pixels_per_inch>63.607452</x_pixels_per_inch>
<y_pixels_per_inch>63.555115</y_pixels_per_inch>
<x_image_size>560.0</x_image_size>
<y_image_size>640.0</y_image_size>
<x_plot_size>420.06363</x_plot_size>
<y_plot_size>461.91858</y_plot_size>
<x_offset_from_left>76.32895</x_offset_from_left>
<y_offset_from_bottom>88.97716</y_offset_from_bottom>
<x_offset_from_right>63.607452</x_offset_from_right>
<y_offset_from_top>88.97716</y_offset_from_top>
<x_axis_lower_left>44.25</x_axis_lower_left>
<y_axis_lower_left>-57.17</y_axis_lower_left>
<x_axis_upper_right>116.25</x_axis_upper_right>
<y_axis_upper_right>22.076</y_axis_upper_right>
</map_scale>

The elements defined in <map_scale> have the following interpretation:

x_pixels_per_inch
number of pixels per 'virtual inch' on the device generating the plot.  This values is not very useful to developers.
y_pixels_per_inch
See above.
x_image_size
width in pixels of the image
y_image_size
height in pixels of the image
x_plot_size
width in pixels of the plotted area  excluding margins on the left and right.
y_plot_size
height in pixels of the plotted area excluding margins on the top and bottom.
x_offset_from_left
number of pixels between the left edge of the image and the left edge of the plotted area  (equivalent to the left margin width)
y_offset_from_bottom
number of pixels between the bottom of the image and the bottom edge of the plotted area  (equivalent to the bottom margin height)
x_offset_from_right
 number of pixels between the right edge of the image and the right edge of the plotted area  (equivalent to the right margin width)
y_offset_from_top
 number of pixels between the top of the image and the top edge of the plotted area  (equivalent to the top margin height)
x_axis_lower_left
world coordinate X value associated with the lower left corner of the plotted area (for XY maps = westernmost longitude)
y_axis_lower_left
world coordinate & value associated with the lower left corner of the plotted area (for XY maps = southernmost latitude)
 x_axis_upper_right
 world coordinate X value associated with the upper right corner of the plotted area (for XY maps = easternmost longitude)
y_axis_upper_right
 world coordinate & value associated with the upper right corner of the plotted area (for XY maps = northernmost latitude)

Using map_scale information in a Velocity template

In order to create a clickable or rubber-bandable product you will need to access these values inside a Velocity template.  The entire map_scale class is available within the Velocity template context as seen in the following snippet:

...

'plot_area' : { // defining the plot region within the image
'offX' : $las_map_scale.getXOffsetFromLeft(),
'offY' : $las_map_scale.getYOffsetFromTop(),
'width' : $las_map_scale.getXPlotSize(),
'height' : $las_map_scale.getYPlotSize()
},

...

Each element of the map_scale object has a getter method whose name is the CamelCase, no-underscore version of the XML element name.



Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: