| Richie 的个人资料The Sandpit - "We hack s...日志列表 | 帮助 |
|
7月31日 Exploiting the ESRI Projection Engine (second edition)Late last year we created a .NET wrapper for the ESRI projection engine (PE). The PE is a C DLL that is used by many ESRI products like ArcGIS Engine, ArcGIS Desktop, ArcGIS Explorer and also Adobe Acrobat Reader 9. Click here to read the previous post. The wrapper has been extended to include two more functions and comes with a test application. Additionally, code was added to safely unload the PE DLL to reduce the risk of memory leaks. The source code (include test application) can be downloaded from here on ArcScripts. Below is a screenshot demonstrating the PE function that computes the geodesic distance (and azimuth) between two geographic locations.
The next screenshot demonstrates another PE function that computes a location on an ellipsoid based using a distance and azimuth from a known location.
The last screenshot demonstrates a PE function that performs a geographic transformation. For a list of preset geographic transformations please visit one of following links (#1, #2 or #3). In the example below, a coordinate based on the Ain El Adb ellipsoid is transformed to the WGS84 ellipsoid.
Convert Decimal Degrees to Degrees Minutes SecondsThis post contains C# code to convert decimal degrees into degrees, minute and seconds. The screenshot below demonstration the code being using to convert a latitude (in decimal degrees) to a correctly formatted DMS value.
Here is the code associated with the button that does the conversion. private void Button_Click(object sender, EventArgs e) { if (sender == this.buttonConvertToDms) { if (string.IsNullOrEmpty(this.textBoxDD.Text)) { return; } double d; if (!double.TryParse(this.textBoxDD.Text, out d)) { return; } CoordinateType type = this.radioButtonLat.Checked ? CoordinateType.latitude : CoordinateType.longitude; this.textBoxDMS.Text = Engine.DDtoDMS(d, type); } else if (sender == this.buttonClose) { this.Close(); } } Lastly, here is the formatting code. Unlike similar sample, this code will pad minutes and seconds with zeros and append a N, S, W or E compass heading. public enum CoordinateType { longitude, latitude }; public static string DDtoDMS(double coordinate, CoordinateType type) { // Set flag if number is negative bool neg = coordinate < 0d; // Work with a positive number coordinate = Math.Abs(coordinate); // Get d/m/s components double d = Math.Floor(coordinate); coordinate -= d; coordinate *= 60; double m = Math.Floor(coordinate); coordinate -= m; coordinate *= 60; double s = Math.Round(coordinate); // Create padding character char pad; char.TryParse("0", out pad); // Create d/m/s strings string dd = d.ToString(); string mm = m.ToString().PadLeft(2, pad); string ss = s.ToString().PadLeft(2, pad); // Append d/m/s string dms = string.Format("{0}°{1}'{2}\"", dd, mm, ss); // Append compass heading switch (type) { case CoordinateType.longitude: dms += neg ? "W" : "E"; break; case CoordinateType.latitude: dms += neg ? "S" : "N"; break; } // Return formated string return dms; } Technorati Tags: C# 7月22日 GeoTagger for ArcGIS DesktopEarlier this year MetaCarta launched a commercial web service called GeoTagger OnDemand,
Today the Prototype Lab at ESRI released an extension for ArcGIS Desktop that uses this service. The extension is called GeoTagger for ArcGIS Desktop and can downloaded from here on ArcScripts. The download includes the complete source code.
Before you can use GeoTagger for ArcGIS Desktop you must create a MetaCarta account and signup to use MetaCarta web services.
Below is a step-by-step example on how to use GeoTagger for ArcGIS Desktop. Start ArcMap and load some content. Display the GeoTagger Toolbar. Click View > Toolbars > GeoTagger. The GeoTagger toolbar consists of a single command. Display the GeoTagger window by clicking on the command. If this is the first time that you have used the GeoTagger tool then click the Options button (third from right) to display the Credentials window. Enter your username (email address) and password that you used to register above. Click the OK button to save your credentials and dismiss the window. In this example, we have web browser that is referencing a New Zealand travel guide web page. The page contains a number of unfamiliar cities and towns. Wen can use GeoTagger for ArcGIS Desktop to convert the geographic names into geographic hyperlinks. To do this, select some text in the browser and drag and drop it to the GeoTagger Window as shown below. Next, the text needs to be submitted to the MetaCarta GeoTagger OnDemand service for processing. This is normally sub-second but may be more if you sent large amounts of text or your have poor bandwidth. Click the fourth button from the right to use the geotagging service. Moments later... ...the text in the GeoTagger window will contain hyperlinks as shown below. MetaCarta's advanced geotagging service was about to identify geographic place names like "North Island" and "New Zealand" but also descriptive locations like "12km south of Auckland". Placing your mouse cursor over the hyperlinks will display a popup tooltip with additional information. Below is a description of the information that is displayed in a geotagged tooltip.
Lastly, right clicking on the hyperlinks will display a menu of actions that can be performed on the geotagged text. In the screenshot below, the user has added callout boxes to the ArcMap display for three geotagged entries. |
|
|