Try using format=image/png instead of format=application/openlayers in your
URL templates.  I'm not sure if this is the only problem but it is
definitely a big one.

ps - on unixy systems you have the file command which is helpful for
checking the output of this sort of thing; "file /tmp/tmpjw3bCA" tells you
what sort of file is at that path.  In this case, it was an HTML document so
that may have clued you in to the problem :)

--
David Winslow
OpenGeo - http://opengeo.org/

On Mon, Feb 14, 2011 at 4:53 AM, Dheeraj Chand <[email protected]>wrote:

> Hi, David,
>
> Thanks for your response on this not long ago. I recently picked this back
> up (Python script attached), and I'm a little confused by the output of it,
> which is also attached.   What exactly am I doing wrong in the WMS call?
>
> Dheeraj
>
> 1. Python script
> 2. Output graphic
>
> # Python written by Dheeraj Chand
> # Purpose: Query the WMS server by loop and write the files to disk.
> # NOTE: I hope that this works.
> # fnord
>
> # Import libraries
>
> import sys      # Useful system functions
> import pdb      # Python debugger
> import psycopg2 # PostgreSQL library
> import urllib   # URL library
>
> # Define variables for WMS Call
>
> base_url = "
> http://localhost:8080/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=Jamaa:Chapters&styles=&bbox=-157.858,-37.826,145.179,64.838&width=974&height=330&srs=EPSG:4326&format=application/openlayers
> "
>
> # Set parameters for database connexion
>
> h = 'localhost'
> p = '5432'
> u = 'dheerajchand'
> pw =
> d =
>
> # Define connexion
>
> conn = psycopg2.connect(host = h, user = u , password = pw , port = p,
> database = d)
>
> # Check connexion
>
> if conn:
>
>     print "Your credentials worked."
>
> else:
>     if not conn:
>
>         print "Your credentials failed. Terminating script."
>         sys.exit()
>
> # Define query to get states and bounding boxes from the table of shapes
> from the Census shapefile
>
> state_rows = "SELECT states.stusps00 AS abbreviation, states.name00 AS
> full_name, ST_Extent(states.the_geom) AS bounding_box FROM states GROUP BY
> full_name, abbreviation ORDER BY full_name;"
>
> # Execute query to get rows
>
> cursor = conn.cursor()
> cursor.execute(state_rows)
> received_state_rows = cursor.fetchall()
>
> # Loop through each the array of returned rows. The goal is to set the bbox
> for each state into the URL call, then save the file to a PNG file named for
> the state.
>
> for row in received_state_rows :
>
>     abbreviation = row[0]
>     full_name = row[1]
>     unmodified_bbox = row[2]
>
>     # Step 1: Get the unnecessary formatting out of the returned bbox to
> convert it to a normal list/tuple
>
>     remove_space = unmodified_bbox.replace(' ',',')
>     left_paren_gone = remove_space.lstrip('BOX()')
>     right_paren_gone = left_paren_gone.rstrip('BOX()')
>
>     modified_bbox = right_paren_gone
>     final_bbox = eval(modified_bbox)
>
>     # Step 2: Parse the new tuple to get the values into separate
> variables.
>
>     minX = str(final_bbox[0])
>     minY = str(final_bbox[1])
>     maxX = str(final_bbox[2])
>     maxY = str(final_bbox[3])
>
>     # Step 3: Define the URL for the WMS call with the new variables just
> defined.
>
>     # Define variables for WMS Call
>
>     wms_url = "
> http://localhost:8080/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=Jamaa:Chapters&styles=&bbox=";
> + minX +"," + minY +","+ maxX +"," + maxY
> +"8&width=974&height=330&srs=EPSG:4326&format=application/openlayers"
>
>     file = urllib.urlretrieve(wms_url)
>
>     pdb.set_trace()
>
>     # Python to save file somewhere
>
>
>
>
>
>
>
> On Jan 11, 2011, at 10:39 AM, David Winslow wrote:
>
> On Tue, Jan 11, 2011 at 3:37 AM, Dheeraj Chand 
> <[email protected]>wrote:
>
>> Hello, everyone,
>>
>> I have a bit of a pickle, but I think that it could be a fun problem to
>> solve. I am copying a friend of mine on this email because he and I have
>> talked about this in the past, and I think that he'd want to see the
>> response. If it's not an inconvenience, please do leave him on the reply
>> line.
>>
>> I have a PostGIS database with roughly 1,800 points that are to be
>> represented as markers. I have been asked to produce anywhere from 1 to 51
>> maps in PNG format: one will be the entire country of the United States of
>> America , and the rest will be for  each individual state in which there is
>> at least one marker. The request is to use a Google Maps Political map as a
>> base layer, or something else showing basic geopolitical data, like state
>> boundary lines, various cities, etc.
>>
>
> It is against the terms of use of Google Maps to use their tiles in
> anything other than a web browser with the Google Maps API loaded.  There is
> also no way in GeoServer to have the WMS generate tiles using anything other
> than GeoServer layers.  Perhaps the 'cultural' data from
> http://www.naturalearthdata.com/downloads/10m-cultural-vectors/ would be a
> better fit (if you load it in GeoServer you can render it along side other
> layers in GeoServer easily.)  Otherwise, you'll probably need to use an
> image manipulation library in PHP to overlay the WMS results on top of
> whatever third-party tiles you are using.
>
>
>> What I would like to do is use either PHP or Python to (I'll assume PHP
>> for now, but can easily switch to Python if that's what people prefer.):
>>
>>
>>    1. Query the DB and find every state for which there is at least one
>>    marker, and write each one of those states to an array called $states.
>>    2. Loop through $states, and for each one, use a WMS call to produce a
>>    PNG of each state, with markers on it, centered on the centroid of the
>>    state, with zoom set to the state level.
>>
>> If you're ok with being tied to a PostGIS backend, it should pretty easy
> to construct both of these requirements as SQL queries.  Check out the docs
> for postgis: http://postgis.refractions.net/docs/ .  You'll probably to
> achieve the first with a join using the Intersects function, and the second
> using the Envelope one.
>
> So, this means that for each state, I have to get the WMS output of both
>> the Google Maps layer AND the points layer, and combine into one PNG.
>>
>
> If you have your political boundaries in GeoServer, this is as easy as
> writing "layers=political,markers" in your WMS query.  If you don't have
> your political boundaries in GeoServer, it will be somewhat tricky to make
> sure the tiles line up.
>
>
>> If anyone has done something like this before, and can help me think
>> through it, I would really appreciate it.  I'm also willing to pay a bit if
>> someone hasn't done it, but is able to, and requires a consulting fee to
>> help.  I'd prefer to get the assist gratis, as this is volunteer work for an
>> NGO, but I understand that talent and time cost money, and the fact that I
>> am volunteering doesn't mean that other people are.
>>
>
> You might also be interested in the Mapfish Print service, which is able to
> pull geospatial data and tiles from various sources and align them for PDF
> output.  If this is intended to be a quick-n-dirty project however,
> modifying the Mapfish print code to output other formats will probably be
> more work than the above approach.
>
>
>> Thanks,
>>
>> Dheeraj
>>
>>
>> ------------------------------------------------------------------------------
>> Gaining the trust of online customers is vital for the success of any
>> company
>> that requires sensitive data to be transmitted over the Web.   Learn how
>> to
>> best implement a security strategy that keeps consumers' information
>> secure
>> and instills the confidence they need to proceed with transactions.
>> http://p.sf.net/sfu/oracle-sfdevnl
>> _______________________________________________
>> Geoserver-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>>
>>
>
>
>
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to