Select to view content in your preferred language

SpatialReference.toMeterFactor

4106
7
06-19-2013 10:17 AM
LarryStout
Deactivated User
I have extended the Esri Draw Widget to work with more spatial references than just Web Mercator and Geographic (4326).  To do this, I needed to determine the units of any projected coordinate system.  It doesn't seem like a huge task, but the only way I could figure out how to do this was to use the toMeterFactor property of SpatialReference.  This requires the use of esri_internal, which I really hate to do.  Is there another way to determine the units of a spatial reference?  If not, can Esri make the toMeterFactor public?  It works great.
Tags (2)
0 Kudos
7 Replies
stevemclaughlin
Occasional Contributor
I have extended the Esri Draw Widget to work with more spatial references than just Web Mercator and Geographic (4326).  To do this, I needed to determine the units of any projected coordinate system.  It doesn't seem like a huge task, but the only way I could figure out how to do this was to use the toMeterFactor property of SpatialReference.  This requires the use of esri_internal, which I really hate to do.  Is there another way to determine the units of a spatial reference?  If not, can Esri make the toMeterFactor public?  It works great.


Yes, please make toMeterFactor public!!! 
I can use it too.
0 Kudos
LarryStout
Deactivated User
Yes, please make toMeterFactor public!!! 
I can use it too.


Bjorne and Heather, if you're out there, we could use this in the JavaScript API as well!  Now that you are part of the JavaScript API team, can you help us?
0 Kudos
BjornSvensson
Esri Regular Contributor
Yes, please make toMeterFactor public!!! 
I can use it too.


Steve, I'd like to understand your use case better.  Could you explain with some more details?  For example, do you need to know the "unit" of the spatial reference of the current map?  Or for any and all projections?  What would you do with that "unit"?  Or do you want to know the conversion factor (compared to meter) for the units on the map?
0 Kudos
BjornSvensson
Esri Regular Contributor
Bjorne and Heather, if you're out there, we could use this in the JavaScript API as well!

Larrye, same question for you.  What is that you are missing from the API and what is it that you are trying to accomplish?  You might to create a new thread under the Javascript forum instead for that...
0 Kudos
LarryStout
Deactivated User
Touche, Bjorn.  Sorry about the extra letter in your name.

I'll detail my requirements both here and in a new thread in the JavaScript Forum, since they are the same.

Originally, I was trying to get the units associated with the spatial reference of the map.  I couldn't find a good way to do that, and came upon the toMeterFactor, and that works as well if not better.  Here is where and how I am using it:

1. When the user clicks on a feature, I show a popup with several tabs.  One of the tabs shows the measurements of the feature area and perimeter for polygons, length for polylines, and coordinates for points.  If the feature was a polygon or a polyline, the popup also shows the coordinates of the point clicked.  In both cases, the user can change the spatial reference of the coordinates or the units of the length and area units.  I call the geometry service to convert the coordinates to a different spatial reference.  If the spatial reference is Web Mercator or Geographic, I can calculate the area and length on the client.  If the spatial reference is projected, I can also calculate the area and length on the client, but I need the map units or the ratio of the units to meters to do that.
2. We use the same popup (not an Esri popup, but our own Flex popup) in the Identify and the Search Widget results.
3. We also need the map units to calculate area and length dynamically in the Draw Widget.
4. We have enhanced the Print Widget to show a graphic on the screen that represents the paper size selected for the print.  It lets the user see what will be printed rather than guess what will be printed.  In this widget, we have to do an approximate projection of the paper into the map coordinate system.  We do this on the client, because the user can drag the paper around the map.

You can see all of these widgets in our "last" Flex Viewer here: http://gis.hamiltoncounty.in.gov/flexviewer/index.html.

I have started porting some of this functionality to a couple of different JavaScript Viewers, Dave Spriggs Configurable JavaScript Viewer that I got from GitHub (http://gis.hamiltoncounty.in.gov/jsViewer3/index.html), and the Stem App JavaScript Viewer that is part of WebApp Builder (http://gis.hamiltoncounty.in.gov/mapViewer1/index.html#).  These implementations are a little rough right now, so be gentle.  The Widget is called Print Plus in the JavaScript Viewers.

Larrye
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Larry,

   Since you are playing around with the StemApp I thought you might be interested in my initial work on a eSearch widget (right now the enhanced just means I am trying to get the search widget up to the level that the otb Flex Search Widget is).

Enhancements over the otb StemApp Search widget:

  1. Widget results are organized vertically.

  2. Field names are italics

  3. Field values are decrypted (coded domains, subtypes, dates are all returned with proper values).

  4. Widget results include a swatch.

  5. When entering text for an attribute search pressing enter executes the search.

  6. Changing the search layer clears the search text box and displays the search hint.

  7. Zoom to all option added to results page.

  8. Result list is in the same field order as specified in the JSON file.

  9. Title field is bold in the results.

  10. Results use an alternating color.

  11. Results have scrollbars for vertical and horizontal if needed.

  12. clearing results takes you back to the initial view.

  13. Initial View is configurable.

  14. Default Search Symbology how has a GUI.

  15. Searches are no re-orderable in the GUI.

  16. Expression textbox now has a prompt for the proper expression format.

  17. Include all fields button added

  18. Date field format is configurable (just not in the GUI yet).

0 Kudos
LarryStout
Deactivated User
Robert,

I've forced myself to finish up my Print Plus Widget (attached) for the StemApp before allowing myself to look at your eSearch Widget.  The WebApp Builder uses responsive design.  It is implemented using a variety of techniques, and I've been exploring them as I need them.  I've tested the Print Plus Widget on an iPhone 4S and an iPad.  I still can't drag the layout around on a touch screen, so that's my next project.  Here's a link to an app with the Print Plus Widget (and the original Print Widget) on my server: http://gis.hamiltoncounty.in.gov/mapViewer1/index.html.

Thanks for the eSearch Widget and enjoy.

Larry
0 Kudos