[Qgis-user] QGISWebserver and PostGIS-Layer

Bernhard Ströbl bernhard.stroebl at jena.de
Mon Nov 26 07:30:33 PST 2012


Hi,

in the Python console enter:
 >>>bbox = qgis.utils.iface.mapCanvas().extent()
 >>>str(bbox.xMinimum()) + "," + str(bbox.yMinimum()) + "," + 
str(bbox.xMaximum()) + "," + str(bbox.yMaximum())

this is the current bounding box of your map for a VERSION=1.1.1 BBOX 
parameter

Bernhard

Am 26.11.2012 16:11, schrieb Albin Blaschka:
> Hello!
>
> So, finally, I resolved my problem - it was twofold:
> The main reason was a problem with the projection of the data, it was
> not properly projected (forgot to specify it for the import to
> postgis...) and secondly, I had to find the right bounding box...
>
> A spontaneous idea: would it be possible to write up a few lines on the
> python console to spit out the correct string, directly usable for the
> bounding box (cut 'n copy) taken from the current map extent...? (Up to
> now, my python experience is close to zero...)
>
> Thanks to Bernhard for his patience and his help!
>
> Albin
>
>
> Am 23.11.2012 09:40, schrieb Bernhard Ströbl:
>> Hi Albin,
>>
>> be sure you reply to the list.
>> It seems that QGIS desktop does not access the same server/same
>> project/same layer as your request. Check the apache access.log and the
>> GetMap request issued by QGIS desktop to find any differences.
>>
>> Bernhard
>>
>> Am 23.11.2012 09:32, schrieb Albin Blaschka:
>>> Hi!
>>>
>>>
>>> Am 23.11.2012 09:11, schrieb Bernhard Ströbl:
>>>> Hi,
>>>>
>>>> do you get a map (and no white image) in QGIS desktop? If yes
>>>> 1) your server is ok but your request is somehow wrong.
>>>> 2) Check your access log and look at the GetMap-request that QGIS
>>>> desktop sends. Compare it to your request.
>>>>
>>>> If no there is something misconfigured, e.g. the SRS of the layer does
>>>> not match the SRS of the data, the database is not accessible from the
>>>> server (check pg_hba.conf)....
>>>>
>>>
>>> Thank you for your patience!
>>> 1.) The map in QGIS Desktop is ok, no problems there! So, yes, the error
>>> lies somewhere with my request.
>>>
>>> 2.) I just checked the PostgreSQL-log (PostgreSQL is running on the same
>>> machine as Apache and is ok): There I found something strange and most
>>> probably the cause for the error: Each time, I make a request via the
>>> Mapserver, I get the error "column 'geom' does not exist" BUT in the
>>> respective table, the geometry column is called "the_geom" and
>>> registered with this name in the geometry_columns-table (I just chekced
>>> that, too). In the qgs-file (the project file), it is also the_geom -
>>> here the relevant part of the qgs-file:
>>>
>>> <projectlayers layercount="1">
>>> <maplayer minimumScale="0" maximumScale="1e+08" geometry="Point"
>>> type="vector" hasScaleBasedVisibilityFlag="0">
>>> <id>verortung20121123083448551</id>
>>> <datasource>dbname='mydatabase' host=myserver port=5432 user='myuser'
>>> password='pwd' sslmode=allow key='gid' srid=4326 type=POINT
>>> table="myschema"."verortung" (the_geom) sql=</datasource>
>>>
>>> I am "slightly" puzzled about that, I just start looking into that
>>> issue...
>>>
>>> Mhmmm...
>>> Thanks,
>>> best regards,
>>> Albin
>>>
>>>
>>>
>>>
>>>
>>>> Bernhard
>>>>
>>>> Am 23.11.2012 08:52, schrieb Albin Blaschka:
>>>>> Hi!
>>>>>
>>>>>
>>>>>
>>>>> Am 23.11.2012 08:02, schrieb Bernhard Ströbl:
>>>>>> Hi Albin,
>>>>>>
>>>>>> try
>>>>>> http://myserver/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image/png&CRS=EPSG:4326&WIDTH=500&HEIGHT=500&LAYERS=mypostgislayer&BBOX=12.96,47.79,12.98,47.81
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> as a major change from 1.1.1 to 1.3.0 is the exchange of x and y
>>>>>> coordinates or use VERSION=1.3.0 and exchange x and y coordinates of
>>>>>> the
>>>>>> BBOX
>>>>>>
>>>>>> if I understand you correctly you get an image as reply but the
>>>>>> image is
>>>>>> all white. So the server is running ok but there are no data in the
>>>>>> place for which you request the map.
>>>>>>
>>>>>
>>>>>
>>>>> Yes, you understand correctly - I followed your example, but no
>>>>> success...
>>>>>
>>>>> Is there a possibility to switch on some kind of logging, additionally
>>>>> to the apache logging? In the apache logs, no errors or warnings or
>>>>> similar appear...
>>>>>
>>>>> Thank you for your help!
>>>>>
>>>>> regards, Albin
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> Am 22.11.2012 17:05, schrieb Albin Blaschka:
>>>>>>>
>>>>>>> Hello!
>>>>>>>
>>>>>>> Thank you for your answer!
>>>>>>>
>>>>>>>> the URL seems to lack the BBOX parameter (I think this is a
>>>>>>>> necessary
>>>>>>>> parameter in a GetMap request)
>>>>>>>> Can you access the maps through QGIS desktop?
>>>>>>>> What happens if you send a GetCapabilities request:
>>>>>>>> http://myserver/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> In QGIS Desktop, everything seems ok, the GetCapabilities-Request
>>>>>>> looks
>>>>>>> also ok - here the head of the answer cut 'n copied:
>>>>>>>
>>>>>>> <WMS_Capabilities version="1.3.0"
>>>>>>> xsi:schemaLocation="http://www.opengis.net/wms
>>>>>>> http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd"><Service><Name>WMS</Name><Title>QGIS-Server</Title><Abstract/><OnlineResource
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> xlink:type="simple"
>>>>>>> xlink:href=""/><ContactInformation><ContactPersonPrimary><ContactPerson>Albin
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Blaschka</ContactPerson><ContactOrganization>LFZ
>>>>>>> Raumberg-Gumpenstein</ContactOrganization></ContactPersonPrimary><ContactVoiceTelephone/><ContactElectronicMailAddress>albin.blaschka at raumberg-gumpenstein.at</ContactElectronicMailAddress></ContactInformation></Service>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ...
>>>>>>>
>>>>>>> Concerning the BBOX:
>>>>>>> I tried it with the following URL (for a small area close to the
>>>>>>> town of
>>>>>>> Salzburg), but again, no success, just a white canvas:
>>>>>>>
>>>>>>> http://myserver/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image/png&CRS=EPSG:4326&WIDTH=500&HEIGHT=500&LAYERS=mypostgislayer&BBOX=12.96,47.79,12.98,47.81
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Albin
>>>>>>>
>>>>>>>>
>>>>>>>> Bernhard
>>>>>>>>
>>>>>>>> Am 22.11.2012 16:12, schrieb Albin Blaschka:
>>>>>>>>> Hello!
>>>>>>>>>
>>>>>>>>> I just started to use QGIS Server on an Ubuntu server, after
>>>>>>>>> installation and basic configuration, I get a successful answer
>>>>>>>>> of a
>>>>>>>>> GetCapability-Request.
>>>>>>>>>
>>>>>>>>> Now, for my first "real" project, I have a question regarding the
>>>>>>>>> QGIS
>>>>>>>>> Server and PostGIS-Layers: If I enter the following URL in
>>>>>>>>> firefox, I
>>>>>>>>> just get a blank canvas, no layer:
>>>>>>>>>
>>>>>>>>> http://myserver/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image/png&CRS=EPSG:4326&WIDTH=500&HEIGHT=500&LAYERS=mypostgislayer
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> What I have done so far:
>>>>>>>>>
>>>>>>>>> * I have set up a project in QGIS Desktop including a
>>>>>>>>> PostGIS-Layer,
>>>>>>>>> with the connection storing the full connection string (username
>>>>>>>>> and
>>>>>>>>> password), the layer is shown as it should be
>>>>>>>>>
>>>>>>>>> * I saved the QGIS project file and opend it in a text editor and
>>>>>>>>> found
>>>>>>>>> the credentials for the PostGIS-Layer
>>>>>>>>>
>>>>>>>>> * I copied the project file into the cgi-bin directory,
>>>>>>>>> chmod'ed it
>>>>>>>>> even
>>>>>>>>> to 777, just to get it going; trying it with the "map="-parameter
>>>>>>>>> was
>>>>>>>>> also not successfull...
>>>>>>>>>
>>>>>>>>> * The database server is the same box as the apache (Ubuntu
>>>>>>>>> Oneiric
>>>>>>>>> 11.10, PostgreSQL 8.3.8, PostGIS Version 1.3; it is an
>>>>>>>>> intranet-server,
>>>>>>>>> not reachable from outside)
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> What have I done wrong?
>>>>>>>>>
>>>>>>>>> Thanks in advance,
>>>>>>>>> best regards,
>>>>>>>>> Albin
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> __________ Information from ESET Mail Security, version of virus
>>>>>>>> signature database 7720 (20121122) __________
>>>>>>>>
>>>>>>>> The message was checked by ESET Mail Security.
>>>>>>>> http://www.eset.com
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Qgis-user mailing list
>>>>>>>> Qgis-user at lists.osgeo.org
>>>>>>>> http://lists.osgeo.org/mailman/listinfo/qgis-user
>>>>>>>
>>>>>>
>>>>>
>>>>
>>
>>
>>
>>
>> __________ Information from ESET Mail Security, version of virus
>> signature database 7722 (20121122) __________
>>
>> The message was checked by ESET Mail Security.
>> http://www.eset.com
>>
>>
>> _______________________________________________
>> Qgis-user mailing list
>> Qgis-user at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-user
>


__________ Information from ESET Mail Security, version of virus signature database 7732 (20121126) __________

The message was checked by ESET Mail Security.
http://www.eset.com





More information about the Qgis-user mailing list