Legal Land Converter Home
Application Programming Interface (API) for Legal Land Converter
Plot a Metes and Bounds Legal Land Description
Plot Land

Search Alberta Corporate Registry
Search Alberta Corporate Registry

Search Edmonton Alberta property by tax account number, street address, legal desciption & lot / block / plan / unit
Search Edmonton Property
Draw a topographic map of Canada with DLS, Water, Rail and Roads
Draw Canada Topo Map

CSV Search

Links
Links
 

Android API



Overview

And http request is created and sent to the webserver. The webserver does the calcuation and returns a text page.

The webpage returned is a text file. It contains one variable / value pair per line. The lines end with CRLF.

The Variable names are all uppercase letters, no embedded spaces, no numbers and no special characters.

The variables end with a colon ':' then there is a single space and then the value until the end of the line marked with CRLF.

The line HAVECONVERSION: 1 appears in a successful conversion.


Canadian DLS Query

Text Sent

http://legallandconverter.com/cgi-bin/android5c.cgi?username=DEVELOPX&password=TEST1234&quarter=SW&section=24&township=12&range=20&meridian=W4&cmd=legal

Text Returned

Content-type: text/plain

STATUSBAR: Version 1.20 Available
LATITUDE: 50.008196
LONGITUDE: -112.614401
UTM: 12N 384323 5540791
MGRS: 12UUA8432240790
NTS: D-10-A/82-I-2
CREDITS: 29
LSD: 
QUARTER: SW
QUARTERLSD: SW
USAQUARTER: 
USASECTION: 
USATOWNSHIP: 
USANORTHSOUTH: 
USARANGE: 
USAEASTWEST: 
USAMERIDIAN: 
USASTATE: 
COUNTRY: Canada
HAVECONVERSION: 1


Valid Meridians are E1, E2, W1, W2, W3, W4, W5, W6, W7 & COAST.


US PLSS Query (by Meridian)

Text Sent

http://legallandconverter.com/cgi-bin/android5c.cgi?username=DEVELOPX&password=TEST1234&usaquarter=NE&usasection=23&usatownship=42&usanorthsouth=N&usarange=23&usaeastwest=W&usameridian=Michigan&cmd=plss

Text Returned

Content-type: text/plain
STATUSBAR: Version 5.00 Available
LATITUDE: 46.025463
LONGITUDE: -87.146129
UTM: 16N 488690 5096887
MGRS: 16TDR8869096886
CREDITS: 82
NTS: N/A
LSD: 
QUARTER: 
QUARTERLSD: 
SECTION: 
TOWNSHIP: 
RANGE: 
EASTWEST: 
MERIDIAN: 
COUNTRY: USA
HAVECONVERSION: 1
List of PLSS Meridians
These exact spellings must be used.

Cimarron
Copper River
Fairbanks
Fifth Principal
First Principal
Fourth Principal
Fourth Principal Extended
Gila and Salt River
Humboldt
Huntsville
Indian
Kateel River
Louisiana
Michigan
Mount Diablo
Navajo
New Mexico Principal
Principal
Salt Lake
San Bernardino
Second Principal
Seward
Sixth Principal
St. Helena
St. Stephens
Tallahassee
Third Principal
Uintah
Umiat
Ute
Washington
Willamette
Wind River


US PLSS Query (by State and County)

Text Sent

http://legallandconverter.com/cgi-bin/android5c.cgi?username=DEVELOPX&password=TEST1234&usasection=29&usatownship=43&usanorthsouth=N&usarange=3&usaeastwest=E&usastate=WI&usacounty=Iron&cmd=plsscounty

Text Returned

STATUSBAR: Version 5.00 Available
LATITUDE: 46.168863
LONGITUDE: -90.136838
UTM: 15N 721022 5116795
MGRS: 15TYM2102216795
CREDITS: 93
NTS: N/A
LSD: 
QUARTER: 
QUARTERLSD: 
SECTION: 
TOWNSHIP: 
RANGE: 
EASTWEST: 
MERIDIAN: 
COUNTRY: USA
HAVECONVERSION: 1
PLSS State Code List

Use the name of the county ie: Marathon

PLSS County List

Use the 2 letter state abbreviation ie: WI


Latitude and Longitude to USA PLSS

Text Sent

http://legallandconverter.com/cgi-bin/android5c.cgi?username=DEVELOPX&password=TEST1234&latitude=48.00820&longitude=-112.61440&cmd=gps

Text Returned


STATUSBAR: Version 4.00 Available
USAQUARTER: NE
USASECTION: 15
USATOWNSHIP: 26
USANORTHSOUTH: N
USARANGE: 8
USAEASTWEST: W
USAMERIDIAN: Principal
USASTATE: MT
COUNTRY: USA
LSD: 
QUARTER: 
QUARTERLSD: 
SECTION: 
TOWNSHIP: 
RANGE: 
EASTWEST: 
MERIDIAN: 
RURALUNIT: 
RURALHOUSE: 
RURALTYPE: 
RURALACCESS: 
MAPQUARTER: D
MAPUNIT: 10
MAPBLOCK: A
MAPSERIES: 82
MAPAREA: A
MAPSHEET: 2
UTM: 12N 379594 5318473
MGRS: 12U UU 79593 18472
CREDITS: 85
HAVECONVERSION: 1

Latitude and Longitude to Canada DLS

Text Sent

http://legallandconverter.com/cgi-bin/android5c.cgi?username=DEVELOPX&password=TEST1234&latitude=50.00820&longitude=-112.61440&cmd=gps

Text Returned

STATUSBAR: Version 5.00 Available
NTS: D-10-A/82-I-2
LSD: 6
QUARTER: SW
QUARTERLSD: SW
SECTION: 24
TOWNSHIP: 12
RANGE: 20
EASTWEST: W
MERIDIAN: 4
COUNTRY: Canada
USAQUARTER: 
USASECTION: 
USATOWNSHIP: 
USANORTHSOUTH: 
USARANGE: 
USAEASTWEST: 
USAMERIDIAN: 
USASTATE: 
UTM: 12N 384323 5540791
MGRS: 12UUA8432340791
CREDITS: 87
HAVECONVERSION: 1

NTS to Latitude and Longitude (Canada)

Text Sent

http://legallandconverter.com/cgi-bin/android5c.cgi?username=DEVELOPX&password=TEST1234&mapquarter=c&mapunit=26&mapblock=F&mapseries=93&maparea=K&mapsheet=11&cmd=nts

Text Returned

STATUSBAR: Version 5.00 Available
LATITUDE: 54.606250
LONGITUDE: -125.321875
NTS: c-26-F/93-K-11
LSD: 4
QUARTER: SW
QUARTERLSD: SW
SECTION: 7
TOWNSHIP: 65
RANGE: 22
EASTWEST: W
MERIDIAN: 7
COUNTRY: Canada
UTM: 10N 350036 6053454
MGRS: 10UCF5003553454
CREDITS: 86
HAVECONVERSION: 1

Latitude and Longitude to MGRS (decimal)

This will resolve successfully to MGRS only.

Text Sent

http://legallandconverter.com/cgi-bin/android5c.cgi?username=DEVELOPX&password=TEST1234&latitude=48.00820&longitude=-112.61440&cmd=mgrsrev1

Text Returned

STATUSBAR: Version 5.00 Available
CREDITS: 62
MGRS: 12U UU 79593 18472
UTM: 12N 379594 5318473
HAVECONVERSION: 1

Latitude and Longitude to MGRS (degree minute second )

Text Sent

This will resolve successfully to MGRS only.

http://legallandconverter.com/cgi-bin/android5c.cgi?username=DEVELOPX&password=TEST1234&latdeg=50&latmin=1&latsec=1&northsouth=N&longdeg=112&longmin=31&longsec=51&eastwest=W&cmd=mgrsrev2

Text Returned

STATUSBAR: Version 5.00 Available
CREDITS: 61
MGRS: 12U UA 90330 41637
UTM: 12N 390330 5541637
HAVECONVERSION: 1

Java Code


Apache Java Libraries

Apache Java Library Documentation

Apache Java Library Download


Java Library HTTP Query Imports


   import org.apache.http.HttpResponse;
   import org.apache.http.NameValuePair;
   import org.apache.http.client.HttpClient;
   import org.apache.http.client.entity.UrlEncodedFormEntity;
   import org.apache.http.client.methods.HttpPost;
   import org.apache.http.impl.client.DefaultHttpClient;
   import org.apache.http.message.BasicNameValuePair;
   

Resource Strings

   
   <string name="url">http://legallandconverter.com/cgi-bin/android5c.cgi</string>
   <string name="version">1.20</string>
   

Query Variables

  
   // GPS

   String latitudevalue   = "";
   String longitudevalue  = "";
   String altitudevalue   = "";
   String accuracyvalue   = "";

   // LEGAL LAND CANADA

   String quarterlsdvalue = "";
   String lsdvalue        = "";
   String quartervalue    = "";
   String sectionvalue    = "";
   String townshipvalue   = "";
   String rangevalue      = "";
   String eastwestvalue   = "";
   String meridianvalue   = "";

   // LEGAL LAND USA

   String usaquartervalue    = "";
   String usasectionvalue    = "";
   String usatownshipvalue   = "";
   String usanorthsouthvalue = "";
   String usarangevalue      = "";
   String usaeastwestvalue   = "";
   String usameridianvalue   = "";
   String usastatevalue      = "";


   
   // Conversion Returned: CANADA or USA
   
   String countryvalue    = "";
   
   

   // COMPOSITES

   String ntsvalue        = "";
   String utmvalue        = "";

   // ACCOUNTING

   String creditsvalue    = "";
   String statusbarvalue  = "";


   // FLAGS

   public int haveconversion = 0;
   public int havegps = 0;

  

Clear Variables

           
   public void ClearResults() 
   {
      latitudevalue = "";
      longitudevalue = "";
      altitudevalue = "";
      accuracyvalue = "";

      lsdvalue = "";
      quarterlsdvalue = "";
      quartervalue = "";
      sectionvalue = "";
      townshipvalue = "";
      rangevalue = "";
      eastwestvalue = "";
      meridianvalue = "";
      
      usaquartervalue = "";
      usasectionvalue = "";
      usatownshipvalue = "";
      usanorthsouthvalue = "";
      usarangevalue = "";
      usaeastwestvalue = "";
      usameridianvalue = "";
      usastatevalue = "";
      
      countryvalue = "";

      ntsvalue = "";
      utmvalue = "";

      creditsvalue = "";
      statusbarvalue = "";

      haveconversion = 0;
      havegps = 0;
      
   }
        
      
  

Build Query and Make Request

       
   public void ContactMothership()
   {
       String version = getResources().getString(R.string.version);
       String url = getResources().getString(R.string.url);
       HttpClient client = new DefaultHttpClient();
       HttpPost   post   = new HttpPost(url);
       try {

          String line = "";                  
          List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
          nameValuePairs.add(new BasicNameValuePair("version",version));
          nameValuePairs.add(new BasicNameValuePair("cmd","legal"));
          nameValuePairs.add(new BasicNameValuePair("username",usernamevalue));
          nameValuePairs.add(new BasicNameValuePair("password",passwordvalue));
          nameValuePairs.add(new BasicNameValuePair("quarter", quarterlsdvalue));
          nameValuePairs.add(new BasicNameValuePair("section", sectionvalue));
          nameValuePairs.add(new BasicNameValuePair("township",townshipvalue));
          nameValuePairs.add(new BasicNameValuePair("range",   rangevalue));
          nameValuePairs.add(new BasicNameValuePair("meridian",meridianvalue));

          post.setEntity(new UrlEncodedFormEntity(nameValuePairs));

          handler.sendEmptyMessage(EXECUTE);
           
          HttpResponse response = client.execute(post);
          
          BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()),8192);
                    
          while ((line = rd.readLine()) != null) 
          {
             ParseLine(line);               
          }
          handler.sendEmptyMessage(FINISH);
       }       
       catch (Exception e) 
       {
         statusbarvalue = e.getMessage();
         handler.sendEmptyMessage(FUBAR);
       }
   }

Parse Results into Java Variables

  
     public void ParseLine(String line) 
     {

      if (line.startsWith("HAVECONVERSION:")) {
         haveconversion = 1;
         return;
      }
      if (line.startsWith("HAVEGPS:")) {
         havegps = 1;
         return ;
      }
      
      // GPS

      if (line.startsWith("LATITUDE:")) {
         latitudevalue = line.substring(10);
         return;
      }
      if (line.startsWith("LONGITUDE:")) {
         longitudevalue = line.substring(11);
         return;
      } 
      if (line.startsWith("ALTITUDE:")) {
         altitudevalue = line.substring(10);
         return;
      } 
      if (line.startsWith("ACCURACY:")) {
         accuracyvalue = line.substring(10);
         return;
      }
      
      // LEGAL LAND CANADA

      if (line.startsWith("QUARTERLSD:")) {
         quarterlsdvalue = line.substring(12);
         return;
      }
      if (line.startsWith("LSD:")) {
         lsdvalue = line.substring(5);
         return;
      }
      if (line.startsWith("QUARTER:")) {
         quartervalue = line.substring(9);
         return;
      }
      if (line.startsWith("SECTION:")) {
         sectionvalue = line.substring(9);
         return;
      }
      if (line.startsWith("TOWNSHIP:")) {
         townshipvalue = line.substring(10);
         return;
      }
      if (line.startsWith("RANGE:")) {
         rangevalue = line.substring(7);
         return;
      }
      if (line.startsWith("EASTWEST:")) {
         eastwestvalue = line.substring(10);
         return;
      }
      if (line.startsWith("MERIDIAN:")) {
         meridianvalue = line.substring(10);
         return;
      }
      

      // LEGAL LAND USA

      if (line.startsWith("USAQUARTER:")) {
         usaquartervalue = line.substring(12);
         return;
      }
      if (line.startsWith("USASECTION:")) {
         usasectionvalue = line.substring(12);
         return;
      }
      if (line.startsWith("USATOWNSHIP:")) {
         usatownshipvalue = line.substring(13);
         return;
      }
      if (line.startsWith("USANORTHSOUTH:")) {
         usanorthsouthvalue = line.substring(15);
         return;
      }
      if (line.startsWith("USARANGE:")) {
         usarangevalue = line.substring(10);
         return;
      }
      if (line.startsWith("USAEASTWEST:")) {
         usaeastwestvalue = line.substring(13);
         return;
      }
      if (line.startsWith("USAMERIDIAN:")) {
         usameridianvalue = line.substring(13);
         return;
      }
      if (line.startsWith("USASTATE:")) {
         usastatevalue = line.substring(10);
         return;
      }
      
      
      // COUNTRY
      
      if (line.startsWith("COUNTRY:")) {
         countryvalue = line.substring(9);
         return;
      }
      
      
      
      // COMPOSITES

      if (line.startsWith("NTS:")) {
         ntsvalue = line.substring(5);
         return;
      }
      if (line.startsWith("UTM:")) {
         utmvalue = line.substring(5);
         return;
      }
      if (line.startsWith("MGRS:")) {
         mgrsvalue = line.substring(6);
         return;
      }
      
      // ACCOUNTING
      
      if (line.startsWith("CREDITS:")) {
         creditsvalue = line.substring(9);
         return;
      }
      if (line.startsWith("STATUSBAR:")) {
         statusbarvalue = line.substring(11);
         return;
      }

      // STATUS MESSAGE / CONVERSION ERROR MESSAGE FROM SERVER
      
      if (line.contains("():")) 
      {
         int ix = line.indexOf(":");
         if (ix != -1 && ix < (line.length() - 2)) 
         {
            statusbarvalue = line.substring(ix + 2);
         }
      }
         
   }

Socket Programming

Perl socket programming tutorial

PERL Socket Programming

Python socket programming tutorial

 
Login

Create an Account

Purchase Credits

Retrieve Lost Password

How to Set Up
an Account

Canada Dominion Land Survey (DLS & ATS) Converter

Canadian Batch Converter
Canadian Batch Converter Help

US Public Land Survey System (PLSS) Converter
PLSS Batch Converter

Military Grid Reference System (MGRS)

National Topographic System (NTS)

Federal Permit System (FPS)

Universal Transverse Mercator (UTM)
Contact Us

Legal Land Converter
Edmonton, Alberta
Phone: 780.455.7226
contact@legallandconverter.com
Copyright © 2024