The following relations were used to link the various coding schemes used, in particular between the POPYCOUN attribute code of PONETD and the country codes in use by FAO (FAOSTAT code). The relations are saved in the file FOWEB.REL.
Relate name |
FAOESRI |
WAIC2POP |
POP2WAIC |
Table |
/app/foweb/cnvcode |
/app/foweb/ctycodes |
/app/foweb/popy2fao |
Database |
INFO | ||
Item |
POPYCOUN |
CTYCODEN |
FAOSTAT |
Column |
POPYCOUN |
FAOSTAT |
CTYCODEN |
Relate type |
LINEAR | ||
Relate access |
RO | ||
This AML will reselect all the polygons that constitute the country from CNTS.
1. &echo &off
2. w /app/foweb
3. relate restore webrel
4. cursor cnts declare ctycodes info rw
5. cursor cnts open
6.
7. &label loopstart
8. &sv cntname = %:cnts.covname%
9. &sv popy = %:cnts.pop2waic//popycoun%
10. &type %cntname% %popy%
11. w /app/foweb/w%cntname%
12.
13. &if [exists country -cover] &then &goto loopend
14.
15. reselect /app/foweb/cnts country poly
16. asel popycoun = [quote %popy%]
17. ~
18. n
19. n
20. build country
21.
22. &describe country
23. &sv :cnts.geoxmin = %dsc$xmin%
24. &sv :cnts.geoymin = %dsc$ymin%
25. &sv :cnts.geoxmax = %dsc$xmax%
26. &sv :cnts.geoymax = %dsc$ymax%
27.
28. &label loopend
29. cursor cnts next
30. &if %:cnts.aml$next% &then &goto loopstart
31.
32. cursor cnts remove
33. &echo &off
This AML will clip hydrology for the region around the country. The RIVERS layer is copied from AW3_INWA in the FORIS/MASTERS workspace.
1. &echo &off
2. w /app/foweb
3. relate restore webrel
4. cursor cnthydro declare ctycodes info rw
5. cursor cnthydro open
6.
7. &label loopstart
8.
9. &type %:cnthydro.covname%
10. w /app/foweb/w%:cnthydro.covname%
11. &if [exists hydro -cover] &then &goto loopend
12.
13. /* clip hydrology in region
14. clip /app/foweb/rivers clip hydro net
15.
16. &label loopend
17. cursor cnthydro next
18. &if %:cnthydro.aml$next% &then &goto loopstart
19.
20. cursor cnthydro remove
21. &echo &off
This is the AML that was used to automatically create the locator maps. Due to its automation and speed of execution, it could be used in an on-line application. The basic skeleton can be adjusted to include other spatial features as well.
There are a number of fixed parameters that could be made variable to accommodate for a wider use. Specifically these relate to the size of the graphic to be produced (currently set to 252 x 152 pixels [44/134-143], with a 1 pixel wide black border [47]), the colours used (in the foweb shadeset and lineset [48/49]), the cities displayed (currently only the capital city [180-210]) and any annotation (none currently, other than the capital city name). Furthermore there are a number of design issues that relate to the mapping itself: the minimum area for mapping (currently set to 1/1000 of the area of the country [59]) and the level of lakes and rivers displayed (dependent on the size of the country [159-165/172-178]). These might have to be adjusted for other mapping purposes. The map is projected based on the spatial extent of the country features to be mapped (i.e. the country, minus the smallest islands). This yields an acceptable and flexible projection, but it may also be substituted for a projection that is commonly used for the country. This would, however, require a substantial reworking of the AML.
When run on the GIS workstation of FRA the AML is sufficiently fast to produce graphics on-the-spot (about 20 seconds for small countries, up to 1'30" for big countries), opening up possibilities for on-line applications. Again, such a use would require substantial adjustments to the AML, particularly with respect to stability and adaptability to user needs.
1. /* LOCMAP.AML
2. /*
3. /* Building the locator maps for the FO web site
4. /*
5. /* Arguments : faostat numeric faostat code
6. /* bmpdir directory where to put the BMP
7. /*
8. /* Dependencies: relate pc2fs
9. /* cnts, capitals, rivers, lakes and seagrid coverages in /app/foweb
10. /* foweb symbolset in /app/foweb
11. /*
12. /* Liabilities : cursor locmap
13. /*
14. /* History : 15/03/99 Original code by Patrick van Laake, portions by Max Lorenzini
15. /* 18/03/99 Map projection added by PvL
16. /* 22/03/99 Updated for alpha1 by PvL
17.
18. &args faostat, gifdir
19.
20. /* 1. Verifying arguments and getting additional data
21. &if [null %gifdir%] &then &sv gifdir = /app/foweb
22.
23. &if %faostat% = 15 &then &do
24. &sv covname = 015
25. &sv popycoun = BE
26. &sv proj = L
27. &end
28. &else &do
29. cursor locmap declare ctycodes info ro faostat = %faostat%
30. cursor locmap open
31. &if not %:locmap.AML$NEXT% &then &do
32. cursor locmap remove
33. &return &error FAOSTAT code %faostat% is not a valid code!
34. &end
35.
36. &sv covname = %:locmap.covname%
37. &sv popycoun = %:locmap.pc2fs//popycoun%
38. &sv proj = %:locmap.proj%
39. cursor locmap remove
40. &end
41.
42. /* 2. Setting up the page
43. ap
44. disp 9999 size canvas 252 152
45. pageunits 72
46. pagesize 252 152
47. maplimits 1 1 251 151
48. shadeset foweb
49. lineset foweb
50. markerset plotter
51.
52. reselect cnts poly popycoun = [quote %popycoun%]
53. &if %faostat% = 15 &then
54. aselect cnts poly popycoun = 'LU'
55. statistics cnts poly popycoun
56. sum area
57. end
58. &sv area = [show statistic 1 1]
59. &sv minarea = %area% / 1000
60. reselect cnts poly area > %minarea%
61. writeselect cnts.sel cnts poly
62.
63. mapex poly cnts
64. &sv mapsize = [show mapextent]
65. &sv xmin = [extract 1 %mapsize%]
66. &sv xmax = [extract 3 %mapsize%]
67. &sv ymin = [extract 2 %mapsize%]
68. &sv ymax = [extract 4 %mapsize%]
69. &sv xmid = ( %xmax% + %xmin% ) / 2
70. &sv ymid = ( %ymax% + %ymin% ) / 2
71.
72. /* 3. Project the map
73. &sv cm = ( %xmax% + %xmin% ) / 2
74. &sv cmd = [truncate %cm%]
75. &sv rest = ( %cm% - %cmd% ) * 60
76. &sv absrest = [abs %rest%]
77. &sv cmm = [truncate %absrest%]
78. &sv cms = ( %absrest% - %cmm% ) * 60
79. &sv cl = ( %ymax% + %ymin% ) / 2
80. &sv cld = [truncate %cl%]
81. &sv rest = ( %cl% - %cld% ) * 60
82. &sv absrest = [abs %rest%]
83. &sv clm = [truncate %absrest%]
84. &sv cls = ( %absrest% - %clm% ) * 60
85.
86. mapprojection automatic *
87. &if %proj% = M &then &do
88. projection mercator
89. units 0.001
90. parameters
91. %cmd% %cmm% %cms%
92. %cld% %clm% %cls%
93. 0
94. 0
95. &end
96. &else &do
97. &sv y6 = ( %ymax% - %ymin% ) / 6
98. &sv p1 = %ymin% + %y6%
99. &sv p1d = [truncate %p1%]
100. &sv rest = ( %p1% - %p1d% ) * 60
101. &sv absrest = [abs %rest%]
102. &sv p1m = [truncate %absrest%]
103. &sv p1s = ( %absrest% - %p1m% ) * 60
104. &sv p2 = %ymax% - %y6%
105. &sv p2d = [truncate %p2%]
106. &sv rest = ( %p2% - %p2d% ) * 60
107. &sv absrest = [abs %rest%]
108. &sv p2m = [truncate %absrest%]
109. &sv p2s = ( %absrest% - %p2m% ) * 60
110.
111. projection lambert
112. units 0.001
113. parameters
114. %p1d% %p1m% %p1s%
115. %p2d% %p2m% %p2s%
116. %cmd% %cmm% %cms%
117. %cld% %clm% %cls%
118. 0
119. 0
120. &end
121.
122. /* 3. Setting the map extent
123.
124. mapex poly cnts
125. &sv mapsize = [show mapextent]
126. &sv xmin = [extract 1 %mapsize%]
127. &sv xmax = [extract 3 %mapsize%]
128. &sv ymin = [extract 2 %mapsize%]
129. &sv ymax = [extract 4 %mapsize%]
130. &sv dx = %xmax% - %xmin%
131. &sv dy = %ymax% - %ymin%
132. &sv dydx = %dy% / %dx%
133.
134. &if %dydx% > 0.6 &then &do
135. &sv div = ( ( %dy% / 0.6 ) - %dx% ) / 2
136. &sv xmin = %xmin% - %div%
137. &sv xmax = %xmax% + %div%
138. &end
139. &else &do
140. &sv div = ( ( %dx% * 0.6 ) - %dy% ) / 2
141. &sv ymin = %ymin% - %div%
142. &sv ymax = %ymax% + %div%
143. &end
144.
145. units projectedmap
146. mapex %xmin% %ymin% %xmax% %ymax%
147.
148. /* 4. Drawing map elements
149.
150. polygonshades seagrid 1
151. clearselect cnts polys
152. reselect cnts polys mapextent
153. reselect cnts poly area > %minarea%
154. reselect cnts poly popycoun <> 'OO'
155. polygonshades cnts 4
156. writeselect reg.sel cnts poly
157. readselect cnts.sel clear
158. polygonshades cnts 3
159. &if %area% > 10 &then
160. reselect lakes poly area > .5
161. &else &if %area% > 4 &then
162. reselect lakes poly area > .05
163. &else &if %area% > 1.6 &then
164. reselect lakes poly area > .005
165. polygonshades lakes 2
166. readselect reg.sel or
167. linesymbol 1
168. linesize 0
169. polygonlines cnts 1000
170. linesymbol 2
171. linesize 0
172. &if %area% > 10 &then
173. reselect rivers arc river_rank < 2
174. &else &if %area% > 4 &then
175. reselect rivers arc river_rank < 3
176. &else &if %area% > 1.6 &then
177. reselect rivers arc river_rank < 4
178. arcs rivers
179.
180. /* 4. Drawing and labeling the capital city
181. reselect capitals point popycoun = [quote %popycoun%]
182. &sv caps = [show select capitals points]
183. &if [extract 1 %caps%] = 1 &then &do
184. markersymbol 46
185. markersize 12
186. textset font
187. textstyle typeset
188. textfont 94023
189. textsize 16 16 pt
190. textcolor black
191. textquality kern
192. &if %faostat% = 15 &then &do
193. pointmarkers capitals 1000
194. pointtext capitals name # LL
195. nselect capitals point
196. reselect capitals point popycoun = 'LU'
197. pointmarkers capitals 1000
198. pointtext capitals name # LR
199. &end
200. &else &do
201. &sv loc = [show select capitals point 1 xy]
202. &if [extract 2 %loc%] > %ymid% &then &sv yloc = U
203. &else &sv yloc = L
204. &if [extract 1 %loc%] > %xmid% &then &sv xloc = R
205. &else &sv xloc = L
206.
207. pointmarkers capitals 1000
208. pointtext capitals name # %yloc%%xloc%
209. &end
210. &end
211.
212. /* 5. Printing the map
213. &sv raster = c%covname%lmap.ras
214. &sv pbm = c%covname%lmap.pbm
215. screensave %raster%
216. &sys %.aml%/rasttopnm %raster% > %pbm%
217. &sys %.aml%/ppmtogif %pbm% > %gifdir%/c%covname%lmap.gif
218. &sys rm %raster%
219. &sys rm c%covname%lmap.rsw
220. &sys rm %pbm%
221.
222. /* 6. Cleaning out, backing up
223. quit
224. &return