;;; -*- Mode: LISP; Package: :cl-user; BASE: 10; Syntax: ANSI-Common-Lisp; -*- ;;; ;;; Touched: Sat Dec 04 17:12:06 2004 +0530 ;;; Time-stamp: <05/01/07 13:13:08 madhu> ;;; (in-package "CL-USER") ;;; Text converted from earth-info.nga.mil/gns/html/gis_contryfiles.html ;;; NGA: GNS; Description of Names Files for Countries and Territories Format ;;; GEOnet Names Server (GNS) ;;; Description of Names ;;; Files for Countries and Territories Format #| Note: The data format is tab-delimited text. The names in the country files are sorted alphabetically and are displayed in Reading order (usually used in mapping applications; ex. Mount Everest) Field Name and Description Field Name Field Description Field Type Maximum Field Length |# (in-package "CL-USER") (defclass metadata () ((RC :documentation "Region Code. A code that determines the character mapping used in the Full_Name field (refer to REGIONS.PDF for character mapping): 1 = Western Europe/Americas; 2 = Eastern Europe; 3 = Africa/Middle East; 4 = Central Asia; 5 = Asia/Pacific; 6 = Vietnam. " :type number ; 1 Digit ) (UFI :documentation "Unique Feature Identifier. A number which uniquely identifies the feature. " :type number ; ± 10 Digits ) (UNI :documentation "Unique Name Identifier. A number which uniquely identifies a name. " :type number ; ± 10 Digits ) (LAT :documentation "Latitude of the feature in ± decimal degrees (WGS84): no sign (+) = North; negative sign (-) = South. " :type number ; ± 2.7 Digits ) (LONG :documentation "Longitude of the feature in ± decimal degrees (WGS84): no sign (+) = East; negative sign (-) = West. " :type number ; ± 3.7 Digits ) (DMS_LAT :documentation "Latitude of the feature in ± degrees, minutes, and seconds (WGS84): no sign (+) = North; negative sign (-) = South. " :type number ; ± 6 Digits ) (DMS_LONG :documentation "Longitude of the feature in ± degrees, minutes, and seconds (WGS84): no sign (+) = East; negative sign (-) = West. " :type number ; ± 7 Digits ) (UTM :documentation "Universal Transverse Mercator coordinate grid reference. character 4 Characters" :type (string 4)) (JOG :documentation "Joint Operations Graphic reference. character 7 Characters " :type (string 7)) (FC :documentation "Feature Classification: A = Administrative region; P = Populated place; V = Vegetation; L = Locality or area; U = Undersea; R = Streets, highways, roads, or railroad; T = Hypsographic; H = Hydrographic; S = Spot feature. character 1 Character " :type character) (DSG :documentation "Feature Designation Code. A two to five-character code used to identify the type of feature a name is applied to. character 5 Characters " :type (string 5)) (PC :documentation "Populated Place Classification. A graduated numerical scale denoting the relative importance of a populated place. The scale ranges from 1, relatively high, to 5, relatively low. The scale could also include NULL (no value) as a value for populated places with unknown or undetermined classification. " :type number ; 1 Digit ) (CC1 :documentation "Primary Country Code. A two alphabetic character code uniquely identifying a geopolitical entity (countries, dependencies, and areas of special sovereignty). character 2 Characters " :type (string 2)) (ADM1 :documentation "First-order administrative division. A two alphanumeric character code uniquely identifying a primary administrative division of a country, such as a state in the United States. character 2 Characters " :type (string 2)) (ADM2 :documentation "Second-order administrative division. The name of a subdivision of a first-order administrative division, such as a county in the United States. variable character 200 Characters " :type (string 200)) (DIM :documentation "Dimension. Usually used to display elevation or population data. " :type number ;± 10 Digits ) (CC2 :documentation "Secondary Country Code. A two alphabetic character code uniquely identifying the country code of a particular name if different than that of the feature. character 2 Characters " :type (string 2)) (NT :documentation "Name Type: C = Conventional; D = Not verified; N = Native; V = Variant or alternate. character 1 Character " :type character) (LC :documentation "Language Code. A two alphabetic character code uniquely identifying a language of a country if multiple official languages are used. character 2 Characters " :type (string 2)) (SHORT_FORM :documentation "A specific part of the name that could substitute for the full name. variable character 128 Characters " :type (string 128)) (GENERIC :documentation "The descriptive part of the full name (does not apply to populated place names). variable character 128 Characters " :type (string 128)) (SORT_NAME :documentation "A form of the full name which allows for easy sorting of the name into alpha-numeric sequence. It is comprised of the specific name, generic name, and any articles or prepositions. This field is all upper case with spaces, diacritics, and hyphens removed and numbers are substituted with lower case alphabetic characters. variable character 200 Characters " :type (string 200)) (FULL_NAME :documentation "The full name is a complete name which identifies the named feature. It is comprised of the specific name, generic name, and any articles or prepositions (refer to REGIONS.PDF for character mapping). variable character 200 Characters " :type (string 200)) (FULL_NAME_ND :documentation "Same as the full name but the diacritics and special characters are substituted with Roman characters (refer to REGIONS.PDF for character mapping). ND = No Diacritics / Stripped Diacritics. variable character 200 Characters " :type (string 200)) (MOD_DATE :documentation "The date a new feature was added or any part of an existing feature was modified (YYYY-MM-DD). date-time 10 Characters " :type (string 10)))) (defun list->record (list) (loop with class = (find-class 'metadata) with object = (make-instance class) for field-name in '(rc ufi uni lat long dms_lat dms_long utm jog fc dsg pc cc1 adm1 adm2 dim cc2 nt lc short-form generic sort_name full_name full_name_nd mod_date) for field in list for field-type = (pcl::slot-type class field-name) when field do (setf (slot-value object field-name) (etypecase field-type (atom (ecase field-type (number (read-from-string field)) (string field) (character (character field)))) (cons (destructuring-bind (type length) field-type (assert (eq type 'string)) (check-type length number) (assert (<= (length field) length)) field)))) finally (return object))) #| (setq $b (make-instance 'metadata)) (setq $a '("5" "-2093658" "-2905062" "18.9166667" "72.8166667" "185500" "724900" "BA79" "NE43-05" "P" "PPLX" NIL "IN" "16" NIL NIL NIL "V" NIL NIL NIL "BOMBAYCOLABA" "Bombay Colaba" "Bombay Colaba" "2003-03-07")) (list->record $a) (inspect $a) ;; load up apicard's csv-parser.lisp #+cmu (progn (require 'csv-parser "home:cl/in/csv-parser") (provide 'csv-parser)) ;; patch it (defun csv-parser::white-space-char-p (char) (or (char= char #\Space) (char= char #\Return) (unless (char= *field-separator* #\tab) #\tab))) (let ((csv-parser:*field-separator* #\tab)) (with-input-from-string (stream "5 -2093658 -2905062 18.9166667 72.8166667 185500 724900 BA79 NE43-05 P PPLX IN 16 V BOMBAYCOLABA Bombay Colaba Bombay Colaba 2003-03-07") (csv-parser:read-csv-line stream))) |#