MySql Spatial Database

Aaron Racicot aaronr at Z-PULLEY.COM
Thu Oct 5 08:42:35 PDT 2006


Hi there Murat,

You need to grab the layer in PHP Mapscript and then you can use the set
method to change layer properties:

http://mapserver.gis.umn.edu/docs/reference/phpmapscript-class/classes/mapob
j

http://mapserver.gis.umn.edu/docs/reference/phpmapscript-class/classes/layer
obj

An example pointing to a raster file on disk:

$oLayer_forward = $oMap->getLayerByName("Model Data");
// set the layer data statement for the "Model Data" layer
$oLayer_forward->set( "data","./model_images/".$name_tif);

Or for a database (PostGIS):

$oLayer_data_gen = $oMap->getLayerByName("Fixed Station");
// set the layer data
$oLayer_data_gen->set( "data","the_geom from (SELECT
data_gen60_".$user_data['uname'].".oid, data_gen60_".$user_data['uname'].".*
FROM data_gen60_".$user_data['uname'].") as foo USING UNIQUE oid USING
SRID=-1");

These are just some examples, but you should look through the MS
documentation to better understand the Mapscript methods that are available
to you from PHP:

http://mapserver.gis.umn.edu/docs/reference/phpmapscript-class


A

+----------------------------------------+
| Aaron Racicot | aaronr at ecotrust.org    |
| GIS Programmer | 503.467.0759          |
+----------------------------------------+
| e c o t r u s t                        |
| Jean Vollum Natural Capital Center     |
| 721 NW Ninth Avenue                    |
| Suite 200                              |
| Portland, OR 97209                     |
| www.ecotrust.org                       |
+----------------------------------------+

-----Original Message-----
From: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU] On
Behalf Of Murat BEYHAN
Sent: Thursday, October 05, 2006 7:26 AM
To: MAPSERVER-USERS at LISTS.UMN.EDU
Subject: Re: [UMN_MAPSERVER-USERS] MySql Spatial Database

Dear Frank 
Thank you this work well.
I have tried the select statement it works fine.
But my problem How can I send condition term from php to map file
I mean by the following statement how can I send the name of districtname
which I intend to draw it. On php the name of district for example $testname
How can I send this information to the map. 
> DATA "SELECT * from polytable WHERE <some condition>"
 DATA "SELECT * from district WHERE districtname='$testname'"
by using %$testname% (%%) this I sent from html but I dont know how can I
send
by using PHP.


Regards 
Murat



On Thu, 5 Oct 2006 10:13:46 -0400, Frank Warmerdam wrote
> Murat BEYHAN wrote:
> > Frank,
> > I'm really getting love mapserver.
> > Its easy to learn and to do any kind of powerful map.
> > But There is another problem.I store the data in the mysql and draw it
but How
> > can I query data stored in mysql by using ogr.
> > I mean how can I send variable from php to OGR
> > 
> > I would like to make select statement for the ogr. But How?
> > By following expression I can draw point layer. But the data are not in
> > spatial database. They are Just table and I read the column from table
for lat
> > lon and by using connectiontype ogr connection I can draw point.
> > My second issiu to draw polygone layer stored in Mysql spatial database.
OK O
> > have succeeded to do, too. And third issiu to draw only one district
which
> > data stored in Mysql spatial databese.
> > So I think I have to construct one select statement as follows but How
can I
> > construct select statement for the mysql spatial database. I dont have
any
> > experiences. Could you give me some point about that. If I could this I
can
> > finalize my study then will be ready to publish it on the net.
> > Regards 
> > Murat
> > 
> > <OGRVRTDataSource>
> >     <OGRVRTLayer name="koymrk">
> >        
> >
<SrcDataSource>MYSQL:bina,user=root,password=mysql_123,host=localhost,port=3
306,tables=zoneson</SrcDataSource>
> >         <SrcSQL>SELECT lat,lon,koyadi from zoneson  </SrcSQL>
> >         <GeometryType>wkbPoint</GeometryType>
> >         <GeometryField encoding="PointFromColumns" x="lon" y="lat"/>
> >     </OGRVRTLayer>
> > </OGRVRTDataSource>
> > ~
> 
> Murat,
> 
> There are a few query concepts that come into play.  MapServer has a 
> concept of query that should operate against your layers without 
> changing the OVF XML or regular connection info.  There should be 
> description of that on the MapServer site ... I've only rarely used 
> it from mapscript.
> 
> But if you just want to draw a reduced set of features based on a custom
> query, there are other ways to handle that.  For the polygon layer
directly
> accessed from MYSQL without an OVF file, you can just put a SELECT
statement
> in your DATA line instead of simply listing a table.
> 
> eg.
> DATA "SELECT * from polytable WHERE <some condition>"
> 
> For the above OVF case you can make the SrcSQL statement more 
> complicated as long as the result set still includes the fields you need.
> 
> Good luck,
> -- 
>
---------------------------------------+------------------------------------
--
> I set the clouds in motion - turn up   | Frank Warmerdam,
warmerdam at pobox.com
> light and sound - activate the windows | http://pobox.com/~warmerdam
> and watch the world go round - Rush    | President OSGeo, http://osgeo.org
> 
> -- 
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.


--
Open WebMail Project (http://openwebmail.org)


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



More information about the MapServer-users mailing list