Discussion:
[OpenLayers-Users] need a little help with this ( user input & wfsprotocol.read )
Diego M.
2012-02-14 11:48:52 UTC
Permalink
*
Hello all

this was my q:*
I'm looking for the best way to apply a search function on my map.
am working on Vector Layer + Geoserver + PostgreSQL.
I want to implement search functionality so that whenever a user gives a
name or id of the feature in search box, he should be zoomed to that
particular feature on the map.
*
I am thankful to Mr.Phil Scadden. he has helping me with it.
he suggest me to do this :*
If layer is on the server, then do filter with WFS to fetch features.
Add them to a "selected" vector layer on the map and then zoomtoExtent
for the selected vector layer. This works for WFS spatial searches too -
(search within polygon, DWithin etc).
*here is my previous post:*
http://osgeo-org.1560.n6.nabble.com/How-to-apply-a-Search-Function-td4364140.html
*
So, I was following the steps but since I have no that much experience in
this field, I'm stuck :/
would anybody please review my code and let me know what's wrong ?
Thank you so much in advance.*

*first, I need to know how wfsprotocol.read should be called in response to
the input submit.
my form in body part is :*
<form name="form" id="form">
<input type="submit" value="submet" id="searchText" />
<input type="text" name="Search" id="searchText" value="Enter... " />
</form>

*
it seems like the code cannot recognize the input text.
all the features are displaying again !
it had to be the one which user input*


var filter = new OpenLayers.Filter.Logical({
type: OpenLayers.Filter.Logical.AND,
filters: [
new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.LIKE,
property: "name",
value: document.getElementById('searchText').value
}),
new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.LIKE,
property: "id",
value: document.getElementById('searchText').value
})
]
});



var strategy = new OpenLayers.Strategy.BBOX({
ratio: 1 // makes for easier comparison to map bounds
});
var wfsProtocol = new OpenLayers.Protocol.WFS.v1_1_0({
url: "IP/geoserver/wfs",
featureType: "Initial_view",
featureNS: "http://mapmap.org",
srsName: "EPSG:3857",
version: "1.1.0",
extractAttributes: true,
isBaseLayer: false,
visibility: true
});

var vessels = new OpenLayers.Layer.Vector("The Vessels", {

styleMap: styleMap,
maxExtent: new OpenLayers.Bounds(-180, -90,
180,90)transform(geographic,mercator),
sphericalMercator: true,
strategies: [strategy],
protocol: wfsProtocol
});

map.addLayers([googleMap , vessels]);


*wfsProtocol.read ({

filter:filter,
callback: processTheQuery,
scope: strategy
});*


function processTheQuery(request) {

// the first bit sets the value of sExt to be the a boundingbox on the
features returned.
// Depending on application logic, this could happen in other places in the
code.
if (request.data && request.data.bbox) {
var b = request.data.bbox;
sExt = new OpenLayers.Bounds(b[0],b[1],b[2],b[3]);
}else {
var fts = request.features;
if (fts.length>0) {
sExt = fts[0].geometry.getBounds().clone();
for(var i=1;i<fts.length;i++) {
sExt.extend(fts[i].geometry.getBounds());
}
}
}
vessels.destroyFeatures(); // get rid of values from previous call

// any other process of the returned features goes here eg display
attributes in a popup
vessels.addFeatures(request.features);
map.zoomToExtent(sExt);
}

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4468479.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Phil Scadden
2012-02-14 21:16:20 UTC
Permalink
Well it looks to me like the wfsprotocol.read is being called with
filters of null so everything comes back.

You need to have
<form name="form" id="form" onsubmit="doSearch()" />

and put the filter creation and wfs read inside that doSearch().

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
Diego M.
2012-02-15 08:46:56 UTC
Permalink
*Thanks that really help!
then I wrote an alert message before filter block and i found out that it
did read what i submetted successfully.
So, either the issue is the filtering itself, or the processTheQuery
function.
coz I had nothing when I write alert message inside it. also all features
comes back.
it seems like that it doesn't call processTheQuery at all*

function doSearch()
{

var value1 = document.getElementById('searchText');
var value2 = value1.value
*alert(value2);*
filter = new OpenLayers.Filter.Logical({
type: OpenLayers.Filter.Logical.OR,
filters: [
new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.LIKE,
property: "name",
value: value2
}),
new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.LIKE,
property: "mmsi",
value: value1.value
})
]
});

wfsProtocol.read ({

filter:filter,

callback: processTheQuery,
scope: strategy
});

}

function processTheQuery(request) {
*alert('test function');*
if (request.data && request.data.bbox) {
var b = request.data.bbox;
sExt = new OpenLayers.Bounds(b[0],b[1],b[2],b[3]);
}else {
var fts = request.features;
if (fts.length>0) {
sExt = fts[0].geometry.getBounds().clone();
for(var i=1;i<fts.length;i++) {
sExt.extend(fts[i].geometry.getBounds());
}
}
}
vessels.destroyFeatures(); // get rid of values from previous call

// any other process of the returned features goes here eg display
attributes in a popup
vessels.addFeatures(request.features);
//map.addLayer(vessels);
map.zoomToExtent(sExt);
}

&lt;b>I also tried callback: processTheQuery(response), but still no luck*

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4471335.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Diego M.
2012-02-15 09:11:31 UTC
Permalink
*I've also tried*

new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.LIKE,
*property: "$name",*
value: value2
}),

since the name column in the DB table is string, still no luck

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4471394.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Diego M.
2012-02-15 09:57:23 UTC
Permalink
*I did some changes and now it is calling processTheQuery successfully!
alert('test function'); is displaying now!
but still all features comes back again

So, *

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4471491.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Phil Scadden
2012-02-15 21:07:49 UTC
Permalink
First, are you using firebug or Chrome? (Seriously, you need these). If
so, any error messages in the console?

If okay, then use the net tab and get the detail of the WFS call. Put up
the details of the GET or POST
so we can look at what the filter is doing.

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
Shadin
2012-02-17 19:52:40 UTC
Permalink
Hello All

I'm trying to implement the same search func and I have questions if you
don't mind.
here:
wfsProtocol.read ({
filter:filter,
callback: processTheQuery,
scope: strategy
});
the (user input text) will be sent to the filter, and if it match any value
in the DB, that feature will be sent to the processTheQuery func to set the
new bounds and draw the new selectedLayer with that feature only.
Do i get it right ?
and if the user insert a wrong value in a search text (which it is not match
any value in the DB ) , what will happen then ?
also, selectedLayer has to be a new layer to display the search results
only. right ?

Thank you all.




--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4481436.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Phil Scadden
2012-02-19 20:40:24 UTC
Permalink
Post by Diego M.
wfsProtocol.read ({
filter:filter,
callback: processTheQuery,
scope: strategy
});
the (user input text) will be sent to the filter,
To be pedantic, the filter is constructed from user input before the read.
Post by Diego M.
and if it match any value
in the DB, that feature will be sent to the processTheQuery func to set the
new bounds and draw the new selectedLayer with that feature only.
Do i get it right ?
The "read" will generate a wfs query post to the server. processTheQuery
has to be able to deal with whatever the server will send back. It has
to determined from the response whether there are matching features
returned.
Post by Diego M.
and if the user insert a wrong value in a search text (which it is not match
any value in the DB ) , what will happen then ?
You will have features.length of zero in the returned response. I would
strongly recommend you use firebug to examine both what the read
generates and what it returns. You can use tools to manually fiddle with
the POST and see the effect.
Post by Diego M.
also, selectedLayer has to be a new layer to display the search results
only. right ?
See earlier posts with the example code, but yes, I create an empty
vector layer where I display results from searching or filtering. This
isnt the only way (eg see
http://openlayers.org/dev/examples/cql-format.js) but it is what works
for me - I am using WMS for display and WFS for query. This structure
lets me use a single procedure (processTheQuery) for both spatial
search, (including a DWITHIN which I use instead of WMSGetFeatureInfo)
and searching by attributes. You needs may be different so study the
filtering examples as well. Also look at the SLDSelect example - if this
works for you, it is fast when have a large number of geometries.

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
Diego M.
2012-02-18 06:20:25 UTC
Permalink
Post by Phil Scadden
First, are you using firebug or Chrome? (Seriously, you need these). If
so, any error messages in the console?
If okay, then use the net tab and get the detail of the WFS call. Put up
the details of the GET or POST
so we can look at what the filter is doing.
*it seems like wfsProtocol.read is never been called !!
there is one WFS call POST
i think it's the Layer main protocol.*

Request URL:http://IP/geoserver/wfs
Request Method:POST
Responce:
<?xml version="1.0" encoding="UTF-8"?>
<wfs:FeatureCollection numberOfFeatures="8991" .... etc (all the features).

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4482442.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Diego M.
2012-02-18 13:33:59 UTC
Permalink
i really want this to be worked :(


(1)
doSearch() wich contains filter + wfsProtocol.read has to be outside the
init() . right ?

(2)
myfilter :
property: "$name" *<< column in db I compare with*
value: document.getElementById('searchText').value

(3)
the main layer display my features from the same wfsProtocol.

(4)
since the user input any text value ( assumed abcd which matches value in db
)
how it would be sent to the processSpatialQuery ? as a feature ?




--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4483135.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Phil Scadden
2012-02-19 20:44:37 UTC
Permalink
Post by Diego M.
(1)
doSearch() wich contains filter + wfsProtocol.read has to be outside the
init() . right ?
Absolutely - they are in response to the user input.
Post by Diego M.
(2)
property: "$name" *<< column in db I compare with*
value: document.getElementById('searchText').value
Yes, but be careful with the syntax here.
Post by Diego M.
(3)
the main layer display my features from the same wfsProtocol.
Well I dont - I always use WMS for display, never WFS. WFS gets slow
very quickly when the no. of features exceeds 500.
Post by Diego M.
(4)
since the user input any text value ( assumed abcd which matches value in db
)
how it would be sent to the processSpatialQuery ? as a feature ?
Its passed in the filter . processSpatialQuery is what is called in
response the the POST that "read" generates.



Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
Diego M.
2012-02-19 11:23:32 UTC
Permalink
I've found out that my problem is in the filter !
still working to fix it ...

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4484990.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Diego M.
2012-02-21 11:35:22 UTC
Permalink
*my filter is working fine now so i don't have any idea why all features are
displaying again when i search for just for some.*
*the WFS POST generates:*

<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS"
version="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><wfs:Query
typeName="feature:Initial_view" srsName="EPSG:3857"
xmlns:feature="http://mapmap.org"><ogc:Filter
xmlns:ogc="http://www.opengis.net/ogc"><ogc:BBOX><gml:Envelope
xmlns:gml="http://www.opengis.net/gml"
srsName="EPSG:3857"><gml:lowerCorner>-1090909.2675342
1510885.0470818</gml:lowerCorner><gml:upperCorner>11109663.437534
4240604.200822</gml:upperCorner></gml:Envelope></ogc:BBOX></ogc:Filter></wfs:Query></wfs:GetFeature>

*
in another side, when i do a normal filter (in vector layer params) :
filter: var my_filter = new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "type",
value: 50
});

it works fine and i got only what i searched for (features with type 50 )
the WFS POST generates:*

<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS"
version="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><wfs:Query
typeName="feature:Initial_view" srsName="EPSG:3857"
xmlns:feature="http://mapmap.org"><ogc:Filter
xmlns:ogc="http://www.opengis.net/ogc"><ogc:And><ogc:PropertyIsEqualTo
matchCase="true">*<ogc:PropertyName>type</ogc:PropertyName><ogc:Literal>50</ogc:Literal></ogc:PropertyIsEqualTo>*<ogc:BBOX><gml:Envelope
xmlns:gml="http://www.opengis.net/gml"
srsName="EPSG:3857"><gml:lowerCorner>-1090909.2675342
1510885.0470818</gml:lowerCorner><gml:upperCorner>11109663.437534
4240604.200822</gml:upperCorner></gml:Envelope></ogc:BBOX></ogc:And></ogc:Filter></wfs:Query></wfs:GetFeature>

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4491047.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Phil Scadden
2012-02-21 19:58:39 UTC
Permalink
Post by Diego M.
<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS"
version="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><wfs:Query
typeName="feature:Initial_view" srsName="EPSG:3857"
xmlns:feature="http://mapmap.org"><ogc:Filter
xmlns:ogc="http://www.opengis.net/ogc"><ogc:BBOX><gml:Envelope
xmlns:gml="http://www.opengis.net/gml"
srsName="EPSG:3857"><gml:lowerCorner>-1090909.2675342
1510885.0470818</gml:lowerCorner><gml:upperCorner>11109663.437534
4240604.200822</gml:upperCorner></gml:Envelope></ogc:BBOX></ogc:Filter></wfs:Query></wfs:GetFeature>
Time to step through with the debugger in firebug. The filter that
generated this does not have real content. Check for js gotchas like
scope, capitalisation etc.


Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
Diego M.
2012-02-21 18:27:06 UTC
Permalink
*after a lot of searches i've read that openlayers is tagging an extra BBOX
to the end of the request. is this might my issue ?*

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4492522.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Phil Scadden
2012-02-22 21:00:25 UTC
Permalink
Post by Diego M.
*after a lot of searches i've read that openlayers is tagging an extra BBOX
to the end of the request. is this might my issue ?*
No, the problem is that the filter in use has no content. You should use
firebug or similar tools to step to the protocol read and see what is
going on with that filter at that point.

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
Diego M.
2012-02-22 18:46:05 UTC
Permalink
*I'm kinda stuck :/
I spent the whole day trying to figure what causes the error but had no
luck.
would you mind please if i post or send u my code so that you take a look
and tell my what's wrong ?
i would be so grateful for your help.*

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4496022.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Phil Scadden
2012-02-22 21:02:24 UTC
Permalink
If you can post the code for web page that we can put on disk and try,
then okay. Trying to spot an error in a code fragment and without being
able to use debug tools is hard.

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
Diego M.
2012-02-23 15:52:43 UTC
Permalink
Here it is
http://osgeo-org.1560.n6.nabble.com/file/n4499046/myCode.txt myCode.txt

Thank you so much.

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4499046.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Phil Scadden
2012-02-23 22:13:55 UTC
Permalink
Post by Diego M.
Here it is
http://osgeo-org.1560.n6.nabble.com/file/n4499046/myCode.txt myCode.txt
Diego - the wfs address of
http:/./192.168.50.195

is a private network address! (192.168.*.* is private). No use to
someone on the outside.

However, the issue are you really fighting is the html style. I have
never written in the old form submit method so didnt spot the
implication earlier. By have a form submit to activate the combo box
the whole page is refreshed and the filter response simply lost. The wfs
protocol you saw in the firebug was simply the vector layer read which
of course is the whole thing.
Instead of form and submit logic, attach onclick handler to the button (eg
http://dev.openlayers.org/releases/OpenLayers-2.11/examples/filter-strategy.html
)
to run dosearch. That should get you on your way. I strongly recommend
you spend more time with the OL examples and make sure you understand
both the html and js.


Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
Diego M.
2012-02-23 22:33:58 UTC
Permalink
Oops
I forgot to remove it.
could you delete it from your post please.

and thanks a lot for this hint!
I will try and let you know about the result


--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4500307.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Diego M.
2012-02-26 07:34:47 UTC
Permalink
*i fixed my form and it's a way better now! Thanks.

but it seems like the wfsProtocol.read doesn't send anything to callback:
processTheQuery
coz i try alert(request.responseText); inside that function and i get alert
with undefined value!
*



--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4508466.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Phil Scadden
2012-02-26 21:43:03 UTC
Permalink
Post by Diego M.
*i fixed my form and it's a way better now! Thanks.
processTheQuery
coz i try alert(request.responseText); inside that function and i get alert
with undefined value!
Well the callback is being called. What do you see in request using
firebug? Also, you can use the Net tab in firebug/chrome tools, to see
both the request and the response.

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
Diego M.
2012-02-27 05:30:47 UTC
Permalink
i get this:

<ows:ExceptionText>*Illegal property name: id*</ows:ExceptionText>
</ows:Exception>

id is a col in my DB and also an attribute in my layer on GeoServer

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4513383.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Diego M.
2012-02-27 11:58:19 UTC
Permalink
*i think my issue kike this:*
http://osgeo-org.1560.n6.nabble.com/WFS-beginner-questions-td3797492.html#a3797493

*except that I'm working on OpenLayers.
*

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4514527.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Diego M.
2012-02-28 10:35:09 UTC
Permalink
*FINALLY IT WORKS!
THAT'S AWESOME!
I'm so thankful to you Mr.Phil.

it works when i restart the Geoserver and DB connection.

now. i noticed that the map is way zoomed in. could i make it be more zoomed
out a little bit ?
*


--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4521552.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Phil Scadden
2012-02-28 19:50:26 UTC
Permalink
Put in a map.zoomToExtent to what opening extent that you want.

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
Diego M.
2012-02-29 03:33:30 UTC
Permalink
*no i meant when i search for feature and display it, there is too zooming.
is there any way to make (sExt) less zooming ? i know it takes a feature's
bounds but i'am wondering if i can do that. *

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4529967.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Phil Scadden
2012-02-29 03:37:30 UTC
Permalink
Just expand the bounds calculated by sEXT a little.

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
Diego M.
2012-02-29 03:40:54 UTC
Permalink
*would you, please show me how to do it ? *


if (request.data && request.data.bbox) {
var b = request.data.bbox;
sExt = new OpenLayers.Bounds(b[0],b[1],b[2],b[3]);
}else {
var fts = request.features;
if (fts.length>0) {
sExt = fts[0].geometry.getBounds().clone();
for(var i=1;i<fts.length;i++) {
sExt.extend(fts[i].geometry.getBounds());
}
}
}

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4529991.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Phil Scadden
2012-02-29 03:51:45 UTC
Permalink
This is trivial - take the bounds left/right/top/bottom and just
add/substract a bit (or maybe a percentage of the bounds width) to each
and extend the bounds to that.

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
Diego M.
2012-02-29 08:27:23 UTC
Permalink
it's hangigng again and i get <ows:ExceptionText>*Illegal property name:
mmsi*</ows:ExceptionText> !!
Do you think that caused by GeoServer ?
i have not change anything!

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4530482.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Phil Scadden
2012-02-29 20:01:32 UTC
Permalink
I'd say formatting of filter. Look at what query it is sending. If
mistake isnt obvious, try fiddling it directly in your browser. Or post
the query here.

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
Diego M.
2012-03-05 13:19:49 UTC
Permalink
*it's stable now and working great.
i think it will be fine.

regarding zoom thing,*
Post by Phil Scadden
Just expand the bounds calculated by sEXT a little.
*i try this but nothing change
am i doing it right ?*

function processTheQuery(request) {

if (request.data && request.data.bbox) {
var b = request.data.bbox;
sExt = new OpenLayers.Bounds(b[0],b[1],b[2],b[3]);
}else {
var fts = request.features;
if (fts.length>0) {
sExt = fts[0].geometry.getBounds().clone();
for(var i=1;i<fts.length;i++) {

&lt;b>var Lbouns = parseFloat((fts[i].geometry.getBounds().left) +
50);
var Rbouns = parseFloat((fts[i].geometry.getBounds().right) + 50);
var Tbouns = parseFloat((fts[i].geometry.getBounds().top) + 50);
var Bbouns = parseFloat((fts[i].geometry.getBounds().bottom) + 50);

var newBounds = new OpenLayers.Bounds(Lbouns, Rbouns, Tbouns, Bbouns);
sExt.extend(newBounds); *

}
}

};

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4547729.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Phil Scadden
2012-03-05 20:52:34 UTC
Permalink
Post by Diego M.
*it's stable now and working great.
i think it will be fine.
regarding zoom thing,*
Post by Phil Scadden
Just expand the bounds calculated by sEXT a little.
*i try this but nothing change
am i doing it right ?*
function processTheQuery(request) {
if (request.data&& request.data.bbox) {
var b = request.data.bbox;
sExt = new OpenLayers.Bounds(b[0],b[1],b[2],b[3]);
}else {
var fts = request.features;
if (fts.length>0) {
sExt = fts[0].geometry.getBounds().clone();
for(var i=1;i<fts.length;i++) {
&lt;b>var Lbouns = parseFloat((fts[i].geometry.getBounds().left) +
50);
Should be -50
Post by Diego M.
var Rbouns = parseFloat((fts[i].geometry.getBounds().right) + 50);
var Tbouns = parseFloat((fts[i].geometry.getBounds().top) + 50);
Likewise -50 to expand the box. Draw yourself a picture to see what you
are doing.


Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
Diego M.
2012-03-06 09:10:30 UTC
Permalink
i did that and calculate the deference, and came up with :

function processTheQuery(request) {
if (request.data && request.data.bbox) {
var b = request.data.bbox;
sExt = new OpenLayers.Bounds(b[0],b[1],b[2],b[3]);
}else {
var fts = request.features;
if (fts.length>0) {
sExt = fts[0].geometry.getBounds().clone();
for(var i=1;i<fts.length;i++) {
var Lbouns = (fts[i].geometry.getBounds().left -1.43085);
var Rbouns = (fts[i].geometry.getBounds().right +0.64564);
var Tbouns = (fts[i].geometry.getBounds().top +1.41458);
var Bbouns = (fts[i].geometry.getBounds().bottom -0.60166);

&lt;b>sExt.extend(new OpenLayers.Bounds(Lbouns, Rbouns, Tbouns,
Bbouns)); *

}
}

};
selectedLayer.destroyFeatures();
selectedLayer.addFeatures(request.features);
*map.zoomToExtent(sExt);*
*
coz my current bounds = 50.23729 , 29.82040 / 50.24007 , 29.81936
and i want it to be = 48.80644 , 30.46604 / 51.65465 , 29.21770*

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4550630.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Diego M.
2012-03-07 03:29:32 UTC
Permalink
*

how i could expand it by a percentage of the bounds width ?
maybe it will work this way*

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4553220.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Diego M.
2012-03-12 20:25:18 UTC
Permalink
*my main problem is with the GeoServer !!
my filter property is the primary key of my layer and i just found out that
the GeoServer does not publish primary key attributes as regular feature
attributes, so i'm keep getting null instead of my id.

is there any solutions for it ? *

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4571521.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Bartłomiej Burkot
2012-03-13 08:34:04 UTC
Permalink
One solution is to add column to attribut table with the same values as
primary key column. If you use postgresql try something like:
alter table yourattributtable add column duplicatedid default id. Then
column duplicatedid appears as regular attribut in geoserver.
Post by Diego M.
*my main problem is with the GeoServer !!
my filter property is the primary key of my layer and i just found out that
the GeoServer does not publish primary key attributes as regular feature
attributes, so i'm keep getting null instead of my id.
is there any solutions for it ? *
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4571521.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Diego M.
2012-03-13 11:10:58 UTC
Permalink
*Thanks!
yes you are right!
but are you sure of this command ?
i get syntax error near default.*

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4573645.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Bartłomiej Burkot
2012-03-14 09:36:44 UTC
Permalink
You are right it is not allowed.
"ERROR: cannot use column references in default expression"
You must use update clouse:
alter yourtable add column additional_id int;
update yourtable set additional_id=id;

If you frequently update your table it is more usefull for you to use
trigger. Look for it in postgresql doc.

Bartlomiej
Post by Diego M.
*Thanks!
yes you are right!
but are you sure of this command ?
i get syntax error near default.*
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4573645.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Diego M.
2012-03-14 13:20:51 UTC
Permalink
*Thank you so much Bartłomiej!
it works perfectly!*

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4578190.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
summer7310
2013-05-28 06:19:58 UTC
Permalink
hi I'm also looking for a way to apply a search function on my map.
The structure like Vector Layer +Geoserver +PostgreSQL+openlayers.\
As you send the code lost on the web site .
Can you send it again and show how does it work .thank you!






--
View this message in context: http://osgeo-org.1560.x6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p5056302.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Albert
2012-03-17 07:14:53 UTC
Permalink
*i tried this functionality for search and it works fine.
but I want to show error message if user insert a wrong test (not included
in id column records)

is this ok ? *

function processTheQuery(request) {
*if (request.data == null)
alert(' please insert again');*


if (request.data && request.data.bbox) {
var b = request.data.bbox;
sExt = new OpenLayers.Bounds(b[0],b[1],b[2],b[3]);
}else {
var fts = request.features;
if (fts.length>0) {
sExt = fts[0].geometry.getBounds().clone();


--
View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4627355.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Continue reading on narkive:
Loading...