#native_company# #native_desc#
#native_cta#

GIS Mapping with PHP; Part Two Page 3

By Simon Moss
on February 9, 2004

E00 has a similar system of storing data but it involves a slightly more long
winded process to get the data out.
For the outline polygons of states and provinces, we only really deal in the
vector type of “REGION” ( a polygon ). MIF files can also contain
PLINES ( a non-filled polygon ) and LINES which our importer can handle, plus
a number of other shape types, which we don’t need or care about. A point to
note at this stage is that there are two types of Polygon – outside and inside.
Basically one type of polygon is a filled area, the other is a hole – think
of a donut. One polygon is the donut, the other is the hole. Due to processing
limitations, we don’t really deal with inside polygons. In later stages we come
up with some cheats to get around this, especially when it comes to lakes and
rivers.
To load the file, we just loop through each line read from the file. When we
detect the start of a region ( by the presence of a string naming the type of
vector object ), we create a new array and start to parse the coordinates into
it. The polygons are stored in PHP in a array of associative arrays, with each
associative array containing the type of vector object we have, the number of
points in the object, the coordinates of the bounding rectangle and a string
containing a space delimited list of coordinates.
At the moment we will load the vector data from a Mapinfo MIF file into the
arrays each time we run the script. This is not the best way to do it for large
amounts of data – however, it is the simplest method for the needs of the article.
In later articles the same function will be used to prepare the data for import
into POSTGRESQL.

1
|
2
|
3
|
4
|
5
|
6
|
7