Post Reply 
GEODATA: A program for finding geographic data
01-15-2017, 11:26 PM (This post was last modified: 01-15-2017 11:28 PM by StephenG1CMZ.)
Post: #1
GEODATA: A program for finding geographic data
This program aims to load and search various geographic data sets.

Note that the data itself is not provided and will normally need to be downloaded (or your own data provided).

CSV data may be loaded using my CSV program.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
01-15-2017, 11:31 PM (This post was last modified: 01-17-2017 10:38 PM by StephenG1CMZ.)
Post: #2
RE: GEODATA: A program for finding geographic data
Version. 0.1 meets the following objectives:
It demonstrates use of my CSV program
It allows airport data to be inspected (actually, it makes no assumptions and will display anything CSV can read if it fits onscreen).
It provides a readable list of locations, that might later be integrated with my GEODESY routines, later allowing distances to be calculated without having to enter latitude and longitude.

Code:


 
 LOCAL GD_ID:="GEODATA V 0.1 © 2017 StephenG1CMZ";
 LOCAL ST;
 LOCAL LF:=CHAR(10);
 LOCAL COMMA:=",";
 LOCAL CR:=CHAR(13);
 //LOCAL YL:=19;

 LOCAL SHO_PROGRESS:=1;//TEST VALUE:IT IS A PARAMETER AND NOT CUSTOMISED
 EXPORT AIRPORTS_DATA:={};
 LOCAL FIELDS:={};
 
 //IMPORT(CSV);

 GD_IDS()
 BEGIN
  TEXTOUT_P(GD_ID,0,20); 
 END;

 EXPORT ABOUT()
 BEGIN
  RECT_P();
  GD_IDS();
  TEXTOUT_P("Data is not included, supply your own files",0,40);
  TEXTOUT_P("Loading AIRPORTS data...Esc to continue",0,60);
  WAIT; 
 END;

 
 
 
 

 EXPORT LOAD_AIRPORTS()
 BEGIN

  LOCAL XXNUM;
  LOCAL FLIST2:="AIR"+{"0","1","2","3","4","5","6","7","8","9"};
  //LOCAL FLIST2:="AIR"+{"0"};//TEST
  //LOCAL FLIST1:={"G7"};
  LOCAL TM;

  PRINT();
  RECT();//CLEAR SCREEN
  GD_IDS();
  XXNUM:=1;
  CSV_SCR_PUT();//SAVE USER SCREEN
  //RECT_P() HERE IF WE WISH TO DISCARD USER SCREEN
  TM:=TICKS; 
  AIRPORTS_DATA:=CSV_Load(FLIST2,−1,XXNUM,1,SHO_PROGRESS);
  CSV_SCR_GET();//RESTORE USER SREEN IF DESIRED
  TEXTOUT_P("Elapsed "+((TICKS-TM)/1000)+" s",0,200,2);//FOR ACCURATE TIMING TAKE TICKS BEFORE SCR_GET
  //MSGBOX("LOADED: "+SIZE(AIRPORTS_DATA));
  L1:=AIRPORTS_DATA;
  WAIT;
 END;

 EXPORT FIND_AIRPORTS(Str)
 BEGIN
  LOCAL II,JJ,CHS,OKC;
  LOCAL FT:=Str;
  LOCAL MYLIST:={};
  LOCAL MYLISTA:={};
 
  //MSGBOX("DATA: "+SIZE(AIRPORTS_DATA));
  FOR II FROM 1 TO SIZE(AIRPORTS_DATA) DO
   //DEBUG;
   FIELDS:=AIRPORTS_DATA(II);
   IF TYPE(FIELDS)≠6 THEN
    //PRINT("DOM: "+{TYPE(FIELDS),II});
   END;
   IF TYPE(FIELDS)==DOM_LIST-1 THEN
    IF SIZE(FIELDS)  AND 1 THEN //NOT EMPTY
     FOR JJ FROM 1 TO SIZE(FIELDS) DO
      IF INSTRING(FIELDS(JJ),FT) THEN
       MYLIST(0):=II;
        //IF MORE THAN ONE FIELD MATCHES
        //AIRPORT IS LISTED TWICE
       DRAWMENU({II,JJ,SIZE(MYLIST)});//MATCHES
      END;
     END;
    END; 
   END;
  
   //DRAWMENU(II);//WAIT(0.1);
  END;
  IF SIZE(MYLIST) THEN
   FOR II FROM 1 TO SIZE(MYLIST) DO
    FIELDS:=AIRPORTS_DATA(MYLIST(II));
    MYLISTA(II):=FIELDS;
   END; 
   REPEAT
    OKC:=CHOOSE(CHS,(SIZE(MYLIST))+" matches",MYLISTA);
   // MSGBOX(MYLISTA(CHS));
    FIELDS:=MYLISTA(CHS);
    IF 1 THEN 
     RECT_P(0,0,320,200);
     FOR II FROM 1 TO SIZE(FIELDS) DO
        TEXTOUT_P((II)+": "+FIELDS(II),0,13*(II));
     END;
    END;
    WAIT;

   UNTIL OKC==0; 
  ELSE
   MSGBOX("NO MATCH...TRY ANOTHER STRING")
  END;

  PRINT("Done");
 END;

EXPORT GEODATA()
BEGIN
 LOCAL OKC,TM,Str;

 RECT_P();
 ABOUT();
 TEXTOUT_P("Loading",0,0);
 
 LOAD_AIRPORTS();
 
 WHILE OKC:=INPUT({{Str,[2]}},"Enter String (Any Data Field)","Find","Ensure strings are in quotes") DO
 
  //TEXTOUT_P("Finding..."+Str,0,0);
  TM:=TICKS;
  FIND_AIRPORTS(Str);
  TM:=TICKS-TM;
  PRINT("Elapsed: "+(TM/1000)+" s");
  WAIT;
 END;

END;

The code has been tested using Airports data formatted as described in this thread, which explains how I had to split the file for the Android.
Link: http://www.hpmuseum.org/forum/thread-7103.html

Note that the dataset is not in CSV format, in that some airport locations include commas within the location strings. The data remains readable, but additional fields are created.
I intend to improve CSV parsing.

Why airports? Apart from previously working on avionics software - There are less than 10 000 listed...(the professional dataset includes more).
So a single list can be searched. And the data is more localised than just listing capital cities.

The initial version makes no assumptions about the data fields.

Update: The input help says strings must be in quotes. Actually, you just need to enter Alpha lock and remove the default 0 (unless searching for a number).

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
01-27-2017, 11:50 PM
Post: #3
RE: GEODATA: A program for finding geographic data
I have just tested this program using the new VC on the PC.
It is able to load the airports datafile without having to split the file as on the Android (just change the filespec accordingly).
On the PC, it loads in 5s. On Android (with the older 8151 VC) it loads in about 130s.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
02-07-2017, 11:28 PM (This post was last modified: 02-09-2017 12:30 AM by StephenG1CMZ.)
Post: #4
RE: GEODATA: A program for finding geographic data
If you use only Android, it is necessary to cut-and-paste and split the file as described above.

If you have access to a PC, either the VC on the PC or the VC on Android can process a single large file, using the new VC. You will need to be able to run VC or CK on the PC, so a library PC won't help.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)