Tuesday, November 11, 2008

BBOX in OpenLayers calls

I made some headway in modifying the BBOX that I had in my OpenLayers portlet example. When I started I wasn't even sure if OpenLayers uses the same Coordinate Reference System as the data from the National Inventory of Dams that I was trying to display.

My OpenLayers wfs call was limiting the number of features to 10 and I knew the approximate geographic area where these 10 dams were located. When the portlet first displayed I wanted the 10 maps to be visible in the window. That wasn't happening and I had spent a lot of time experimenting with the OpenLayers map constructor and Bounds constructor. The numbers didn't seem to match up to what I was seeing. I was also using Firebug to look at the URL that was being sent to the WFS by the code in my proxy servlet. After the Scott Davis GIS talk at this past weekend's Software Symposium I thought the problem might be related to the map projections.

By examining the XML in a WFS file that I had previously created from accessing the WFS I could see that the data used EPSG:4326. This was a good page that helped me understand what that meant: http://en.wikipedia.org/wiki/European_Petroleum_Survey_Group Then I went to OpenLayers and did some research and found that the default projection used by OpenLayers is also EPSG:4326. That meant that the problem was not that I had 2 different projections. Finally on one of the OpenLayers FAQs I found a suggested way to get the map to appear where I wanted it to appear.
http://faq.openlayers.org/map/how-do-i-get-a-specific-bounds-to-load-just-right-into-my-map-div/

There was still some tweaking that was needed to get the proportions in the window to be correct but I now have the features showing in the map when it first displays. The Bounds parameters I used were (-90,31,-80,40). The BBOX that is in the URL being sent to the WFS is BBOX=-95,25.5,-75,45.5. I need to do some more research to understand the correlation between these two. ie, how does OpenLayers come up with that BBOX? My next goal is to pinpoint the location where the user clicks the mouse and have the information for that feature returned in the portlet. Always more to learn in this stuff. I sure wish I knew where there was a book on OpenLayers.

No comments: