Using mysql to generate map

Robert Hollingsworth reh2 at PRODIGY.NET
Sat Sep 8 11:16:01 EDT 2007


I've had good results with mySQL, php_mapscript on mswin.  I'd also found
the documents to be a bit difficult on the subject.  In the std docs,  look
at what OGR docs have to say about mysql.  Ignore anything you see on the
"MYGIS" CONNECTIONTYPE; I've exclusively been using the MySQL support under
OGR.  All my efforts have been using the MySQL Spatial constructs.

Some quick notes that should help:

1.  As mentioned, only use OGR support for MySQL.
2.  I'm assuming you're using MySQL Spatial Geometry only.
3.  Make sure your Geometry column has a Spatial Index if you want to do
spatial queries (see DATA statement below).
4.  Build or otherwise make sure (ogrinfo.exe) that your GDAL lib supports
MySQL.
5.  mapfile extract:
LAYER
	NAME "MySQLdata"
	TYPE point
	STATUS DEFAULT
	CONNECTIONTYPE OGR
	CONNECTION
"mysql:databasename,user=mysqluser,password=mysqlpasswd,host=mysqlhost,port=3306"
# make sure your port is really 3306.  fill in the actual values for db user
passwd host, of course

	DATA "select attr1,attr2,geom from tablename where attr1 not like '%HH' and
MBRIntersects(GeomFromText('Polygon((-98 29,-98 30,-97 30,-97 29,-98 29))'
),shape)"
	LABELITEM attr2
	CLASSITEM attr1
	CLASS
		EXPRESSION /...[0-9][0-9]/
......
6.  The DATA statement above, from some zipcode data I've done, shows a
WHERE clause; you can use whatever SQL you need (joins, etc.).  It's
possible that the OGR driver will actually make all your attributes
available to you without their explicit mention in the DATA statement, but I
haven't experimented with all the variations.
7.  The DATA statement also illustrates a spatial query -- pretty essential
for performance if you want to pull a small amount of data from a large dataset.

I hope this helps.  have fun.

REH

>>>>>>>>>>>>>>>>> original:
>I am using mysql db and php as mapscript on windows. In mysql db i have got
coordinates of the points thst i need to show on the map. I dont have any
base map (on which i can add point). What i mean to say is that i have just
point coordinates and nothing else( Except the extent and projections). Now
i want to read those points from the database and display them on map and
attaching some information with those individual points (like labels and
link to open pop up) Please let me know how it can be done.
>I tried searching for some documentation regarding using mysql as db but
couldnt find relevant document. If you have found one please let me know the
address.



More information about the mapserver-users mailing list