[OpenLayers-Users] getting Feature Info data directly from .shpfiles

Robert Sanson SansonR at asurequality.com
Tue Mar 23 19:11:30 EDT 2010


Why have you got FORMAT: 'png' for a GetFeatureInfo request in your click event?
 
I think you should work on getting a GetFeatureInfo request that works from your browser URL directly with Mapserver. Once you have the correct URL and a correct response from Mapserver, then you can work on implementing in OL.
 
regards,
 
Robert

>>> sunny74 <sb.ray at hotmail.com> 24/03/2010 3:00 a.m. >>>

Hi Bwoodall,

That example doesn't work.
I am using the GetfeatureInfo example of OL27.

My code is as follows:


<script type="text/javascript" language="javascript">
          var mapview, layer, layer1, map,base;

          OpenLayers.ProxyHost = "OL27/examples/proxy.cgi?url=";
//          var map = new OpenLayers.Map('map', );
          function init() {

              //alert("in init");
              map = new OpenLayers.Map('<%=map.ClientID%>',{
'maxResolution': 'auto' });

              //
              layer = new OpenLayers.Layer.WMS("OpenLayers WMS",
                "http://172.16.0.144:9000/cgi-bin/mapserv.exe?", { map:
'Shape/newwr1.map', layers: 'STATE', 'format': 'png' });

              layer1 = new OpenLayers.Layer.WMS("BASIC",
                "http://172.16.0.144:9000/cgi-bin/mapserv.exe?", { map:
'Shape/newwr1.map', transparent: 'true', layers: 'RailwayStations',
'format': 'png' });
             // base = new OpenLayers.Layer.WMS("Base",
"http://172.16.0.144:9000/cgi-bin/mapserv?map=Shape/newwr1.map", { layers:
["state"] });
              base = new OpenLayers.Layer.WMS("Base",
"http://mapsvr/cgi-bin/mapserv.exe?map=Shape/newwr1.map", { layers:
["STATE"] });

//              var wms = new OpenLayers.Layer.WMS("OpenLayers WMS",
              //       
"http://world.freemap.in/cgi-bin/mapserv?map=/www/freemap.in/world/map/factbook.map",
{ 'layers': 'factbook' });
              
              map.addLayers([layer, layer1,base]);
              map.zoomToMaxExtent();
              map.setCenter(new OpenLayers.LonLat(73.25, 20.35), 6);

              map.events.register('click', map, function(e) {
                  alert('clicked');
                  OpenLayers.Util.getElement('nodeList').innerHTML =
"Loading... please wait...";
                  var url = base.getFullRequestString({
                      REQUEST: "GetFeatureInfo",
                      EXCEPTIONS: "application/vnd.ogc.se_xml",
                      FORMAT: 'png',
                      BBOX: map.getExtent().toBBOX(),
                      X: e.xy.x,
                      Y: e.xy.y,
                      INFO_FORMAT: 'text/plain',
                      EPSG: 4326,
                      QUERY_LAYERS: "STATE",
                      FEATURE_COUNT: 6,
                      WIDTH: map.size.w,
                      HEIGHT: map.size.h
                  });
                  //  var msg = document.getElementById('urlmsg');
                  //  msg.value = url;
                  alert(url);
                  OpenLayers.loadURL(url, '', this, setHTML);
                  OpenLayers.Event.stop(e);
              });
               
          }

          function setHTML(response) {
              OpenLayers.Util.getElement('nodeList').innerHTML =
response.responseText;
          }


          
      
      </script>

But again this is throwing error:

#!/usr/bin/env python """This is a blind proxy that we use to get around
browser restrictions that prevent the Javascript from loading pages not on
the same server as the Javascript. This has several problems: it's less
efficient, it might break some sites, and it's a security risk because
people can use this proxy to browse the web and possibly do bad stuff with
it. It only loads pages via http and https, but it can load any content
type. It supports GET and POST requests.""" import urllib2 import cgi import
sys, os # Designed to prevent Open Proxy type stuff. allowedHosts =
['www.openlayers.org', 'openlayers.org', 'labs.metacarta.com',
'world.freemap.in', 'prototype.openmnnd.org', 'geo.openplans.org',
'sigma.openplans.org', 'www.openstreetmap.org'] method =
os.environ["REQUEST_METHOD"] if method == "POST": qs =
os.environ["QUERY_STRING"] d = cgi.parse_qs(qs) if d.has_key("url"): url =
d["url"][0] else: url = "http://www.openlayers.org" else: fs =
cgi.FieldStorage() url = fs.getvalue('url', "http://www.openlayers.org")
try: host = url.split("/")[2] if allowedHosts and not host in allowedHosts:
print "Status: 502 Bad Gateway" print "Content-Type: text/plain" print print
"This proxy does not allow you to access that location (%s)." % (host,)
print print os.environ elif url.startswith("http://") or
url.startswith("https://"): if method == "POST": length =
int(os.environ["CONTENT_LENGTH"]) headers = {"Content-Type":
os.environ["CONTENT_TYPE"]} body = sys.stdin.read(length) r =
urllib2.Request(url, body, headers) y = urllib2.urlopen(r) else: y =
urllib2.urlopen(url) # print content type header i = y.info() if
i.has_key("Content-Type"): print "Content-Type: %s" % (i["Content-Type"])
else: print "Content-Type: text/plain" print print y.read() y.close() else:
print "Content-Type: text/plain" print print "Illegal request." except
Exception, E: print "Status: 500 Unexpected Error" print "Content-Type:
text/plain" print print "Some unexpected error occurred. Error text was:", E 

Why are these erors comin?
How to solve?

thanks.
-- 
View this message in context: http://n2.nabble.com/getting-Feature-Info-data-directly-from-shp-files-tp4767879p4783758.html 
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users at openlayers.org 
http://openlayers.org/mailman/listinfo/users 

------------------------------------------------------------------
The contents of this email are confidential to AsureQuality. If you have received this communication in error please notify the sender immediately and delete the message and any attachments. The opinions expressed in this email are not necessarily those of AsureQuality. This message has been scanned for known viruses before delivery. AsureQuality supports the Unsolicited Electronic Messages Act 2007. If you do not wish to receive similar communications in future, please notify the sender of this message.
------------------------------------------------------------------


This message has been scanned for malware by SurfControl plc. www.surfcontrol.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100324/aaa6f100/attachment.html


More information about the Users mailing list