[mapserver-users] RE: Highlight

Jay Kapalczynski jkapalczynski at ci.maple-grove.mn.us
Tue Apr 14 07:30:05 PDT 2009


Thanks for the help and response....I think I am getting closer...

I set up another php page...this page is getting the PID values sent to it via a session, I am using frames in this page
It was the only way I could get the queries to work, the table to build...etc
You can see the "session" code below...I echo it and all the correct PIDs are displayed so I know that I have passed to correctly.
I added your code example...

Note: the PID string is a comma delimited string of PID values

I am pointing the frame to the PHP page and I get this, but no image.  So part of my code is working....

String:0711922340036,0711922340038,0711922340039

But that's it....there is no jpeg...
Again I am very green to this....this is my first attempt to actually return an image... here...

I tried to add this : for my reference library for the ms_newMapObj but I get errors...
So I went back to the GeoMOOSE libraries...(As see below)
No errors but no image

dl('php_mapscript.so');

I am going to try and post this on their site but help is hard to find...
Anyone else out here on the MapServer page mess around with GeoMOOSE...

THANK YOU MOEN for your help it is very appreciated..

<?php
session_start();
$varPIDValue = $_SESSION["PIDString"];

// Echo the session values  THIS GIVES ME A COMMA DELIMITED STRING OF PID VALUES
// MAYBE I HAVE TO EXPLODE THEM FIRST?
echo "String:".$varPIDValue;

error_reporting(E_ERROR | E_PARSE);

# Include the GeoMOOSE PHP Library Utilities
include('Configuration.php');
include('geomoose_php_util.php');



$map = ms_newMapObj('/ms4w/apps/GeoMOOSE/Maple_Grove_GeoMoose/select.map');
$qlayer = $map->$map->getLayerByName('parcels');
$qlayer->queryByAttributes('PID','PID IN ($PIDString)',MS_MULTIPLE);
$img = $map->drawQuery();
$map->selectOutputFormat('jpeg');
header('Content-Type: image/jpeg');
$img->saveImage("");
$image_url=$img->saveWebImage();
?>

<HTML>
  <HEAD>
      <TITLE>Displaying a map</TITLE>
  </HEAD>

  <BODY>
      <IMG SRC=<?php echo $img; ?> >
  </BODY>
</HTML>





From: Moen, Paul T. [mailto:pmoen at nd.gov]
Sent: Monday, April 13, 2009 3:22 PM
To: Jay Kapalczynski
Cc: mapserver-users at lists.osgeo.org
Subject: Re: [mapserver-users] RE: Highlight


On 4/13/09 2:25 PM, "Jay Kapalczynski" <jkapalczynski at ci.maple-grove.mn.us> wrote:
I am messing around with this....does any of this map sense?
Yes, you have many errors.  Check the error logs for php to help debugging with syntax.
// THE QUERY HAPPENS BEFORE THIS....JUST SHOWING THAT THE VARAIBLE HOLDING ALL THE PIS VALUES IS BELOW

//===============================================================
//===============================================================
// BUILD A COMMAN DELIMITED LIST

// if something already in $PIDString, append a comma
if (isset($PIDString))
    $PIDString .= ',';

// Append the new value
$PIDString .= $PID;
//===============================================================
//===============================================================

} // end while


//===============================================================
//===============================================================

$map = ms_newMapObj(/ms4w/apps/GeoMOOSE/Maple_Grove_GeoMoose/select.map);
Won't work because it requires a string, so you would need $map = ms_newMapObj('/ms4w/apps/GeoMOOSE/Maple_Grove_GeoMoose/select.map');

$qlayer = $map->$map->getLayerByName(parcels);
Won't work because it requires a string and the layer in your mapfile is Parcels, so you would need $qlayer = $map->getLayerByName('Parcels');

$qlayer->queryByAttributes('PID','($PIDString)',MS_MULTIPLE);
Won't work because it needs to know how to query for the PID as in $qlayer->queryByAttributes('PID','PID IN ($PIDString)',MS_MULTIPLE);

$img = $map->drawQuery();
Should set the output format to jpeg
$map->selectOutputFormat('jpeg');

header('Content-Type: image/jpeg');
$img->saveImage("");


Can I then test the jpeg in another window or something...
You could set up your php file to accept $_GET variables and pass in the PIDs like below.
http://yourserver.com/phpfilename.php?PID=1%2C2%2C3%2C4%2C5, which should give you a png image after making changes above.
Is this all that I need code wise?
That should give you the basics.  You will also need to load the php_mapscript library before any of the above functions will be recognized. Check out http://mapserver.org/mapscript/php/by_example.html.  There is an abundance of good documentation on http://mapserver.org.
HERE is the select.map file

MAP
                NAME 'all layers'
                SIZE 800 650
                STATUS ON
                EXTENT  427632.500000 4893613.330000 560300.922104 5015936.680000
                UNITS METERS

                SYMBOLSET 'symbols/symbol.sym'

                TRANSPARENT TRUE
                IMAGETYPE PNG

                QUERYMAP
                                STATUS ON
                                STYLE SELECTED
                                #STYLE HILITE
                END

                WEB
                IMAGEPATH "/ms4w/tmp/ms_tmp/"
    IMAGEURL "/ms_tmp/"
    #EMPTY '../geomoose/query_miss.html'
                END



 LAYER # Parcels Polygon Layer
                    NAME 'Parcels'
                    DATA 'parcels/parcels.shp'
                    STATUS ON
                    TYPE POLYGON

                                #TEMPLATE 'parcels/identify_parcels.html'
                                #FILTERITEM 'PID'
                    #FILTER /^%id%/

                    METADATA
                                qstring_validation_pattern '.'
                     END
                    HEADER 'parcels/select_header.html'
                    TEMPLATE 'parcels/select_parcel.html'
                    FOOTER 'parcels/select_footer.html'
                    TOLERANCE 0
                                CLASS
                                SYMBOL 'plainline'
                                SIZE 3
                                COLOR -1 -1 -1
                                OUTLINECOLOR 255 255 0
                                END
  END

From: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Moen, Paul T.
Sent: Thursday, April 09, 2009 3:15 PM
To: mapserver-users at lists.osgeo.org
Subject: Re: [mapserver-users] RE: Highlight


If the database that you are querying has the same attributes as the shape file, you can query the Layer that points to the shape file and display the highlighted results on your map.  I know nothing about GeoMOOSE but I know it can be done with php-mapscript.

Regardless of what you are using, you need a map file layer for the shape file with the parcels.
You will then need to use php-mapscript to query that layer with something like
$map = ms_newMapObj(PATH TO YOU MAPFILE);
$qlayer = $map->$map->getLayerByName(NAME OF PARCEL LAYER);
$qlayer->queryByAttributes('PID','PID IN (1, 2,7,9,23,87)',MS_MULTIPLE);
You will then need to create the output image from query using something like
$img = $map->drawQuery();
header('Content-Type: image/jpeg');
$img->saveImage("");

I can't give you specifics without knowing how GeoMOOSE works, so the best thing is to look at the documentation for GeoMOOSE if that is what you are using.

On 4/9/09 2:17 PM, "Jay Kapalczynski" <jkapalczynski at ci.maple-grove.mn.us> wrote:
Dang I misspoke...I am sorry...

I am querying a Database for records, these records have a PID (unique Number).
These are the records that show up in the Table.

As this happens I have to take the results and run the query against the parcels to get the features in the Shapefile, then highlight..

If that makes any sense...

If I am in a PHP file and have the records returned from the query (database)...what would I have to do next to take those records and run a query to highlight the parcels (PID to PID)?

Can all of this be accomplished in the PHP file?

Thanks...and sorry for my ignorance...




From: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Moen, Paul T.
Sent: Thursday, April 09, 2009 1:57 PM
To: mapserver-users at lists.osgeo.org
Subject: Re: [mapserver-users] RE: Highlight

Set the mapfile QUERYMAP style to highlight http://mapserver.org/mapfile/querymap.html.   Draw the map using drawQuery() instead of draw().

$img = $map->drawQuery();
header('Content-Type: image/jpeg');
$img->saveImage("");

On 4/9/09 1:31 PM, "Jay Kapalczynski" <jkapalczynski at ci.maple-grove.mn.us> wrote:
Basically what I have is a query that runs on a shapefile...
It returns the records into a table, which I then have the option to zoom to.

I am looking for a bit more....after I run the query (php) I want the returned records to highlight in the map...
I can get the Unique identifier but don't know if I can write some code in PHP to highlight those features

I don't even know where to start here...

The query and returning records into the table, as well as, the zoom to work great...just need the highlight part

Thanks



From: Jay Kapalczynski
Sent: Thursday, April 09, 2009 1:03 PM
To: 'mapserver-users at lists.osgeo.org<mapserver-users at lists.osgeo.org> <mapserver-users at lists.osgeo.org> <mapserver-users at lists.osgeo.org> '
Subject: Highlight

Any way to highlight a feature in my map in PHP?

I can grab a unique identifier but can figure out how to highlight it...

THanks

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20090414/69cabd89/attachment.htm>


More information about the MapServer-users mailing list