postgis mapfile php

View: New views
9 Messages — Rating Filter:   Alert me  

postgis mapfile php

by nickthegreek- :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

i have map who takes the data from a database

in the database there is a column "name"

my data are be shown with

 LAYER
                NAME "country"
                TYPE POLYGON
                STATUS ON
            CONNECTIONTYPE postgis
            CONNECTION "host=localhost dbname=postgis user=postgres password=d3klw7 port=5432"
            DATA "the_geom from europe_country using unique gid using srid=-1"
            LABELITEM "name"

what i wanna is.. i have a menu who takes all the countries from the column name...
if i select a country

eg.greece

how i could change the statement in the mapfile
DATA "the_geom from europe_country using unique gid using srid=-1"
with the statement
DATA "the_geom from europe_country where name=greece using unique gid using srid=-1" so to be shown only greece??? pls help me..i need to finish my diploma with taht


eg..i knnow if we wanna to change the status of a layer we use that
  $this_layer = $map->getLayerByName('europe cities');
  $this_layer->set('status', MS_ON);

sth similar like the above to change the statement of data?

Re: postgis mapfile php

by nickthegreek- :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


nickthegreek- wrote:
i have map who takes the data from a database

in the database there is a column "name"

my data are be shown with

 LAYER
                NAME "country"
                TYPE POLYGON
                STATUS ON
            CONNECTIONTYPE postgis
            CONNECTION "host=localhost dbname=postgis user=postgres password=d3klw7 port=5432"
            DATA "the_geom from europe_country using unique gid using srid=-1"
            LABELITEM "name"

what i wanna is.. i have a menu who takes all the countries from the column name...
if i select a country

eg.greece

how i could change the statement in the mapfile
DATA "the_geom from europe_country using unique gid using srid=-1"
with the statement
DATA "the_geom from europe_country where name=greece using unique gid using srid=-1" so to be shown only greece??? pls help me..i need to finish my diploma with taht


eg..i knnow if we wanna to change the status of a layer we use that
  $this_layer = $map->getLayerByName('europe cities');
  $this_layer->set('status', MS_ON);

sth similar like the above to change the statement of data?

also.. i wanna know sth else.. in the mapfile ..i have in data
DATA "the_geom from europe_country using unique gid using srid=-1"

if i changed it in DATA "the_geom from europe_country where name="Greece" using unique gid using srid=-1"
 it should be shown greece ?? right?

but nothing is shown ..it gives me error ...knows anyone what is wrong?

Re: postgis mapfile php

by Stephen Woodbridge :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

nickthegreek- wrote:

>
>
> nickthegreek- wrote:
>> i have map who takes the data from a database
>>
>> in the database there is a column "name"
>>
>> my data are be shown with
>>
>>  LAYER
>>                 NAME "country"
>>                 TYPE POLYGON
>>                 STATUS ON
>>             CONNECTIONTYPE postgis
>>             CONNECTION "host=localhost dbname=postgis user=postgres
>> password=d3klw7 port=5432"
>>             DATA "the_geom from europe_country using unique gid using
>> srid=-1"
>>             LABELITEM "name"
>>
>> what i wanna is.. i have a menu who takes all the countries from the
>> column name...
>> if i select a country
>>
>> eg.greece
>>
>> how i could change the statement in the mapfile
>> DATA "the_geom from europe_country using unique gid using srid=-1"
>> with the statement
>> DATA "the_geom from europe_country where name=greece using unique gid
>> using srid=-1" so to be shown only greece??? pls help me..i need to finish
>> my diploma with taht
>>
>>
>> eg..i knnow if we wanna to change the status of a layer we use that
>>   $this_layer = $map->getLayerByName('europe cities');
>>   $this_layer->set('status', MS_ON);
>>
>> sth similar like the above to change the statement of data?
>>
>
>
> also.. i wanna know sth else.. in the mapfile ..i have in data
> DATA "the_geom from europe_country using unique gid using srid=-1"
>
> if i changed it in DATA "the_geom from europe_country where name="Greece"
> using unique gid using srid=-1"
>  it should be shown greece ?? right?
>
> but nothing is shown ..it gives me error ...knows anyone what is wrong?

Try something like:

DATA "the_geom from ( select gid, the_geom from europe_country where
name='Greece') as foo
  using unique gid using srid=-1"
_______________________________________________
postgis-users mailing list
postgis-users@...
http://postgis.refractions.net/mailman/listinfo/postgis-users

Re: postgis mapfile php

by nickthegreek- :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

stephen it worked that..may thanks.. do  u have an answer also for the previous question??
how could i change the where=greece in the mapfile

with any country i select from a menu

i try ..

this_layer->set("Data","the...geom....... ");

but it doesn't work

RE: postgis mapfile php

by Gabe Codina :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

There are two ways you can do that

$layer->set("data", "the_geom ....");

Or

$layer->setFilter("name = 'Greece'");

Hope that helps

Gabe

> -----Original Message-----
> From: postgis-users-bounces@... [mailto:postgis-
> users-bounces@...] On Behalf Of nickthegreek-
> Sent: Monday, 7 April 2008 10:46 AM
> To: postgis-users@...
> Subject: Re: [postgis-users] postgis mapfile php
>
>
> stephen it worked that..may thanks.. do  u have an answer also for the
> previous question??
> how could i change the where=greece in the mapfile
>
> with any country i select from a menu
>
> i try ..
>
> this_layer->set("Data","the...geom....... ");
>
> but it doesn't work
> --
> View this message in context: http://www.nabble.com/postgis-mapfile-
> php-tp16530438p16531835.html
> Sent from the PostGIS - User mailing list archive at Nabble.com.
>
> _______________________________________________
> postgis-users mailing list
> postgis-users@...
> http://postgis.refractions.net/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
postgis-users@...
http://postgis.refractions.net/mailman/listinfo/postgis-users

Re: postgis mapfile php

by pcreso :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Try:

DATA "the_geom from europe_country where country='%country%' using unique gid
using srid=-1"

& make sure you pass the value for country in your HTML template,

I have a similar app highlighting a species cautght during a biodiversity
survey:

The mapfile has a layer using an SQL to select the text to match for a given
species (I'm using like, so need the double '%%', it uses a query to generate a
virtual table which contains the result of the query, & I used the name myquery
for this virtual table:

LAYER
    NAME spp
    TYPE line
    STATUS on
    CONNECTIONTYPE POSTGIS
    CONNECTION "dbname=stations user=baw host=localhost port=5432"
    DATA "track from (select track,
                             station_no
                       from station where station_no in
                        (select distinct station_no from catch
                         where species like '%%spp%%')
                       order by station_no)
                        as myquery using unique station_no using srid=4326"
....

The html template allows users to enter the species code & turn the layer on:

...
      <INPUT type=checkbox name=layer value="spp" [spp_check]>Species  
      <INPUT type="text" name="spp" size=3  value="[spp]" >
...

I think this is the sort of thing you are looking for?

Also, you have an error in your SQL below,
 
the_geom from europe_country where name="Greece"

the " should be ' around the string 'Greece' for a Postgres string query.

If you turn debug on in mapserver, you can see the Postgres error message
displayed on screen when you open the page in your browser, to help diagnose &
fix errors like this.


Cheers,

   Brent Wood


> nickthegreek- wrote:
> >
> > i have map who takes the data from a database
> >
> > in the database there is a column "name"
> >
> > my data are be shown with
> >
> >  LAYER
> >                 NAME "country"
> >                 TYPE POLYGON
> >                 STATUS ON
> >             CONNECTIONTYPE postgis
> >             CONNECTION "host=localhost dbname=postgis user=postgres
> > password=d3klw7 port=5432"
> >             DATA "the_geom from europe_country using unique gid using
> > srid=-1"
> >             LABELITEM "name"
> >
> > what i wanna is.. i have a menu who takes all the countries from the
> > column name...
> > if i select a country
> >
> > eg.greece
> >
> > how i could change the statement in the mapfile
> > DATA "the_geom from europe_country using unique gid using srid=-1"
> > with the statement
> > DATA "the_geom from europe_country where name=greece using unique gid
> > using srid=-1" so to be shown only greece??? pls help me..i need to finish
> > my diploma with taht
> >
> >
> > eg..i knnow if we wanna to change the status of a layer we use that
> >   $this_layer = $map->getLayerByName('europe cities');
> >   $this_layer->set('status', MS_ON);
> >
> > sth similar like the above to change the statement of data?
> >
>
>
> also.. i wanna know sth else.. in the mapfile ..i have in data
> DATA "the_geom from europe_country using unique gid using srid=-1"
>
> if i changed it in DATA "the_geom from europe_country where name="Greece"
> using unique gid using srid=-1"
>  it should be shown greece ?? right?
>
> but nothing is shown ..it gives me error ...knows anyone what is wrong?
> --
> View this message in context:
> http://www.nabble.com/postgis-mapfile-php-tp16530438p16531664.html
> Sent from the PostGIS - User mailing list archive at Nabble.com.
>
> _______________________________________________
> postgis-users mailing list
> postgis-users@...
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>

_______________________________________________
postgis-users mailing list
postgis-users@...
http://postgis.refractions.net/mailman/listinfo/postgis-users

Re: postgis mapfile php

by Jonathan W. Lowe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, 2008-04-06 at 17:19 -0700, nickthegreek- wrote:

>
>
> nickthegreek- wrote:
> >
> > i have map who takes the data from a database
> >
> > in the database there is a column "name"
> >
> > my data are be shown with
> >
> >  LAYER
> >                 NAME "country"
> >                 TYPE POLYGON
> >                 STATUS ON
> >             CONNECTIONTYPE postgis
> >             CONNECTION "host=localhost dbname=postgis user=postgres
> > password=d3klw7 port=5432"
> >             DATA "the_geom from europe_country using unique gid using
> > srid=-1"
> >             LABELITEM "name"
> >
> > what i wanna is.. i have a menu who takes all the countries from the
> > column name...
> > if i select a country
> >
> > eg.greece
> >
> > how i could change the statement in the mapfile
> > DATA "the_geom from europe_country using unique gid using srid=-1"
> > with the statement
> > DATA "the_geom from europe_country where name=greece using unique gid
> > using srid=-1" so to be shown only greece??? pls help me..i need to finish
> > my diploma with taht
> >
> >
> > eg..i knnow if we wanna to change the status of a layer we use that
> >   $this_layer = $map->getLayerByName('europe cities');
> >   $this_layer->set('status', MS_ON);
> >
> > sth similar like the above to change the statement of data?
> >
>
>
> also.. i wanna know sth else.. in the mapfile ..i have in data
> DATA "the_geom from europe_country using unique gid using srid=-1"
>
> if i changed it in DATA "the_geom from europe_country where name="Greece"
> using unique gid using srid=-1"

Might be the single vs double quotes -- try this instead:

DATA "the_geom from europe_country where name='Greece'
using unique gid using srid=-1"

>  it should be shown greece ?? right?
>
> but nothing is shown ..it gives me error ...knows anyone what is wrong?

_______________________________________________
postgis-users mailing list
postgis-users@...
http://postgis.refractions.net/mailman/listinfo/postgis-users

Re: postgis mapfile php

by Kyle Wilcox :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

FYI this thread was also started on the Mapserver mailing list.

$this_layer->set("data","the_geom from ( SELECT gid, the_geom FROM
europe_country WHERE name='England') AS foo USING UNIQUE gid USING
srid=-1");


nickthegreek- wrote:

> i have map who takes the data from a database
>
> in the database there is a column "name"
>
> my data are be shown with
>
>  LAYER
>                 NAME "country"
>                 TYPE POLYGON
>                 STATUS ON
>             CONNECTIONTYPE postgis
>             CONNECTION "host=localhost dbname=postgis user=postgres
> password=d3klw7 port=5432"
>             DATA "the_geom from europe_country using unique gid using
> srid=-1"
>             LABELITEM "name"
>
> what i wanna is.. i have a menu who takes all the countries from the column
> name...
> if i select a country
>
> eg.greece
>
> how i could change the statement in the mapfile
> DATA "the_geom from europe_country using unique gid using srid=-1"
> with the statement
> DATA "the_geom from europe_country where name=greece using unique gid using
> srid=-1" so to be shown only greece??? pls help me..i need to finish my
> diploma with taht
>
>
> eg..i knnow if we wanna to change the status of a layer we use that
>   $this_layer = $map->getLayerByName('europe cities');
>   $this_layer->set('status', MS_ON);
>
> sth similar like the above to change the statement of data?

--

  Kyle Wilcox
  NOAA Chesapeake Bay Office
  410 Severn Avenue
  Suite 107A
  Annapolis, MD 21403
  office: (410) 295-3151
  Kyle.Wilcox@...

  A: It takes over twice as long to understand the conversation.
  Q: What's wrong with top-posting?
  A: Top-posting.
  Q: What's the worst thing about plain text email discussions?
_______________________________________________
postgis-users mailing list
postgis-users@...
http://postgis.refractions.net/mailman/listinfo/postgis-users

Re: postgis mapfile php

by nickthegreek- :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

<select namex="mydropdown">

  <?php  
  for ($lt = 0; $lt < pg_numrows($myresult); $lt++) {
    $id = pg_result($myresult, $lt, 0);
   
                                            ?>
    <option value="name"> <?php echo $id;?> </option>
      <?php
  }
 
                                       ?>
                       </select>
                     
                       <input type="checkbox" name="layer[]" value="countries"  <?php echo $countries;?> >


i have this select whick takes the results from a column from a database... i haven;t put this select in a form cause it will be inside an othe form .. but i think it works perfect as it nows...

how can i take the selected value from the menu? which is ?   $namex?   $mydropdown??

and how can i put it here.. like ..

the_geom from ( select gid, the_geom from europe_country where name='$namex') as foo using unique gid using srid=-1