Re: [OpenLayers-Users] Need help on the best way to approach feature attribute editing

2010-03-14 Thread Stephen Woodbridge
Hi Eric,

Thank you for your response. I have a lot more working now, but I'm 
afraid I did not explain part of my problem very clearly before. Let me 
first try to explain that better as it will put into context some of my 
questions. What I'm struggling with is keeping the feature data in the 
browser in sync with the data in the database when we are editing. Let 
me talk through each of the CRUD examples.

Create:

We create a new feature in OL, and display it in the vector layer.
The feature is saved to the server where a GID is assigned to it.
I can have the server respond by sending back the complete feature in 
response to the create request. I now need to delete the "temporary" 
feature and replace it with the completed feature.

So I think I just figured out that I should hook the code for this to 
the create callback.

Read:

This is straight forward and just gets data from the server and clears 
the layer and repopulates it. No problems here.

Update:

I have two update cases because of how I built the UI:
1) update my dragging feature to new location (modifyfeature control)
2) update by editing attributes (select control)

After the feature is modified, it is sent to the server via UPDATE. 
Again the issue is how to keep them in sync. I can also have the server 
respond with the updated feature and replace the vector feature with the 
one returned from the server using the callback.

Delete:

I think this one is a little easier, we wait for the server 200 response 
and then remove the feature in the vector layer. I did run into a 
problem with delete in that it does not appear to have a way to say WHAT 
to delete. In OL2.8, it appears that the data line is missing:

   resp.priv = OpenLayers.Request.DELETE({
   url: url,
   callback: this.createCallback(this.handleDelete, resp, options),
   headers: options.headers,
   data: this.format.write(feature) // missing in OL2.8
   });

or is it communicating that some other way? I passed an new delete: 
function(){...} in my protocol constructor and that seems to have fixed 
the problem.

Does this sounds like the right approach for updating the features as 
they change during editing? or are there better practices.

I currently have the OL application generating all the requests 
correctly as far as I can tell. The server is getting them, and ignoring 
them at the moment until I finish coding the appropriate server behaviors.

http://imaptools.com:8080/tilecache/test.html?zoom=17&lat=33.89595&lon=35.49935&layers=BT

Many of my questions below were coming from:
1) the fact the I had not understood how Protocol.HTTP worked, I think I 
have the basics of this down now and
2) the fact that the popup form really does not know what feature it is 
working on. When the form is rendered that code has access to the 
feature and populates the form fields and form is rendered and the code 
goes out of scope. Later the user fills in the form and clicks a button 
which causes the onClick handler to be called, the onClick handler code 
does not know what feature it is working with. I resolved this problem 
by saving a reference to the feature at 
mytoolbar.selCtrl.openpopup.feature which the onClick handle can now 
access. I was trying to avoid using global references, but this works 
fine and allowed me to move forward with the code. I suppose I could 
have add a hidden variable to the form with the feature DOM id and 
recovered the feature using that.

Thank you for your time and your comments. They were very helpful and 
pointed me the right direction where I adequately explained myself. I 
think I just have a couple more pieces of code to finish up and some 
server side work to have a running application.

Best regards,
   -Steve

Eric Lemoine wrote:
> On Saturday, March 13, 2010, Stephen Woodbridge  
> wrote:
>> Hi all,
>>
>> I'm stuck on the best conceptual approach to editing feature attributes
>> and could really use some feedback or other ideas. In part because I
>> think I'm too tangled in all the code parts and have lost the big picture.
>>
>> So at a high level I need:
>>
>> 1) base map - check works fine
>> 2) vector layer pulling data from server - check works fine
>> 3) toolbar with [Nav][createPOI][dragPOI][selectPOI] - check have this
>> but might need to rethink it
>> 4) [createPOI]
>>a) needs to take click on map - check, works fine
>>b) open popup to allow setting attribute, check have this but ...
>>c) have [cancel] to abort creation - have button but how to abort
> 
> for a new feature "cancel" should just destroy that feature.
> 
> for an updated feature "cancel" should go back to the initial feature,
> cloning the feature prior modification may help.
> 
>>d) have [save] to write the data to the server - have button but how
>> to save
> 
> If you use a protocol you can use protocol.create([feature]) or
> protocol.commit([featute]). I'm not sure I'm answering your
> question...
> 
>>e) update layer with new 

Re: [OpenLayers-Users] Questions on using Protocol.HTTP and custom XML to load/edit features

2010-03-14 Thread Stephen Woodbridge
Eric Lemoine wrote:
> On Wed, Mar 10, 2010 at 6:21 PM, Stephen Woodbridge
>  wrote:
>> I'm running OL 2.8, I have not tried trunk.
>>
>> http://imaptools.com:8080/tilecache/test.html?zoom=17&lat=33.89595&lon=35.49935&layers=BT
>>
>> This is a work in progress, that is getting edits, but demonstrates the
>> issue.
>>
>> 1) Turn on Firebug
>> 2) load the page
>> 3) verify in the FB->"Net" tab that
>> http://imaptools.com:8080/tilecache/poi-server.php?...
>> has not been called.
>> 4) Either pan view slightly ot toggle Vector layer off/on in layerswitcher
>> 5) Notice in FB->"Net" tab the poi-server.php is called.
> 
> Hi Steve.
> 
> I think I know what's going on, and it isn't a bug in the lib.
> 
> init does not call zoomToMaxExtent, because the ArgParser control,
> which the map constructor includes by default, already called
> setCenter. The ArgParser calls setCenter when the WMS layer is added,
> i.e. before the BBOX strategy is activated, so the BBOX strategy
> doesn't catch the first moveend. I'm pretty sure that setting controls
> to null in the map options makes the problem go away.
> 
> Cheers,
> 

Hi Eric,

Thanks that worked. I added:

controls: [],

to my map definition and it cleared up the problem. That is a very 
subtle effect that I'm not sure I would have figured out on my own.

Best regards,
   -Steve
___
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users


Re: [OpenLayers-Users] Questions on using Protocol.HTTP and custom XML to load/edit features

2010-03-14 Thread Eric Lemoine
On Wed, Mar 10, 2010 at 6:21 PM, Stephen Woodbridge
 wrote:
> I'm running OL 2.8, I have not tried trunk.
>
> http://imaptools.com:8080/tilecache/test.html?zoom=17&lat=33.89595&lon=35.49935&layers=BT
>
> This is a work in progress, that is getting edits, but demonstrates the
> issue.
>
> 1) Turn on Firebug
> 2) load the page
> 3) verify in the FB->"Net" tab that
> http://imaptools.com:8080/tilecache/poi-server.php?...
> has not been called.
> 4) Either pan view slightly ot toggle Vector layer off/on in layerswitcher
> 5) Notice in FB->"Net" tab the poi-server.php is called.

Hi Steve.

I think I know what's going on, and it isn't a bug in the lib.

init does not call zoomToMaxExtent, because the ArgParser control,
which the map constructor includes by default, already called
setCenter. The ArgParser calls setCenter when the WMS layer is added,
i.e. before the BBOX strategy is activated, so the BBOX strategy
doesn't catch the first moveend. I'm pretty sure that setting controls
to null in the map options makes the problem go away.

Cheers,

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemo...@camptocamp.com
http://www.camptocamp.com
___
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users


[OpenLayers-Users] NS_ERROR_NOT_INITIALIZED with Vector and WFS layer

2010-03-14 Thread paweluz

Hi!

I am using OpenLayers 2.8 ang Geoserver. I have tried two approach
- WFS layer 
- Vector layer with WFSProtocol
and all the times I have this error:

uncaught exception: [Exception... "Component returned failure code:
0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIXMLHttpRequest.send]"  nsresult:
"0xc1f30001 (NS_ERROR_NOT_INITIALIZED)"  location: "JS frame ::
http://localhost:1234/geoserver/www/tasmania/openlayers/OpenLayers.js ::
anonymous :: line 1081"  data: no] Line 0

I work with the tasmania_roads layer from the geoserver samples...
Is there a way to solve this error. Or maybe more important question ... can
it cause any problems with working of my application?? My goal is to be able
to get attributes from layer, save, delete and modify data function using
WFS-T.
Recently I have been trying also to use GTW and Openlayers and this error
also appears

Can anyone tell me please how to fix this?? I may show my code if someone
wants to see this

Regards,
Poul

-- 
View this message in context: 
http://n2.nabble.com/NS-ERROR-NOT-INITIALIZED-with-Vector-and-WFS-layer-tp4733242p4733242.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
___
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users


Re: [OpenLayers-Users] Pink tiles in FireFox doesn't disappear after refresh - a possible solution

2010-03-14 Thread Pietro Ianniello
WOW!
I was looking on nabble if my post was arrived, made a search and...I have
just found another "solution" like mine!
http://n2.nabble.com/Possible-pink-tile-fix-td1827492.html by Ben Brehmer.
It's interesting, He appends "&retry="+this._attempts;
and by using a temporary var doesn't have to check if it was added or not.

Do have someone else verified it? If yes, will it be included in future OL
versions?

Pietr Ianniello



On Sun, Mar 14, 2010 at 6:16 PM, Pietro Ianniello <
pietro.iannie...@gmail.com> wrote:

> Dear list,
>
> this is second time I make this post: for some reason the first post was
> lost... and it's good because it was buggy!
>
> On to the problem: pink tiles showing up in FireFox.
>
> The pink tiles are generated because of too many connections, so my problem
> it's not that there are pink tiles, the problem it's that when the server is
> reachable again, if I for ex. zoom in and out, they don't desappear as they
> should.
> This is because of aggressive caching on tile to be displayed. If I disable
> caching on server side for tiles, they behave ok... bu I want tiles to be
> able to cache them on clients!
>
> After some days fighting against this problem, enabling caching, disabling
> caching.. I decided to inspect Openlayers code. It' not all really
> clear, but I realized that the problem *can be* related to "*
> OpenLayers.Util.onImageLoadError*".
> Finally I realized that changing it as reported will fix my problem:
>
> OpenLayers.Util.onImageLoadError = function() {
> this._attempts = (this._attempts) ? (this._attempts + 1) : 1;
> if (this._attempts <= OpenLayers.IMAGE_RELOAD_ATTEMPTS) {
> var urls = this.urls;
> if (urls && urls instanceof Array && urls.length > 1) {
> var src = this.src.toString();
> var current_url, k;
> for (k = 0; current_url = urls[k]; k++) {
> if (src.indexOf(current_url) != -1) {
> break;
> }
> }
> var guess = Math.floor(urls.length * Math.random());
> var new_url = urls[guess];
> k = 0;
> while (new_url == current_url && k++ < 4) {
> guess = Math.floor(urls.length * Math.random());
> new_url = urls[guess];
> }
> this.src = src.replace(current_url, new_url);
> } else {
> this.src = this.src;
> }
> *OpenLayers.Console.log("attemp n.:",this._attempts);*
> } else {
> *OpenLayers.Console.log("error loading", "appending uuu!");**
> var dummy = "&uuu";
> if (this.src.match(dummy + "$") != dummy) { //only add if it was
> not added before
> this.src = this.src + "&uuu";
> }*
> this.style.backgroundColor = OpenLayers.Util.onImageLoadErrorColor;
> }
> this.style.display = "";
> };
>
> That is: I change the the url of the tile appending some dummy character
> [in this case "uuu", but it can be anything].
> This can be done only if the dummy string was not added before [first post
> bug: I didn't check it]. If you don't check It and the address *this.src*is 
> wrong, you will get OL to continue adding the dummy string going in loop
> and bombardig the server with requests.
> I don't know enough OL to understand why, but that's it.
>
> I would like to have comments from people who knows OL better than me about
> this "solution".
>
> NOTE: it's possible to use the same technique without modifying OL, doing
> something *like* [untested - must be sure about what is '*this*' in the
> context]:
>
> OpenLayers.Util.oldOnImageLoadError = OpenLayers.Util.onImageLoadError;
> OpenLayers.Util.onImageLoadError = function() {
>this.oldOnImageLoadError();
>if (this._attempts >= OpenLayers.IMAGE_RELOAD_ATTEMPTS) {
>   //TODO: add dummy
>}
> }
>
> Pietro Ianniello
>
>
>
>
___
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users


Re: [OpenLayers-Users] Need help on the best way to approach feature attribute editing

2010-03-14 Thread Eric Lemoine
On Saturday, March 13, 2010, Stephen Woodbridge  wrote:
> Hi all,
>
> I'm stuck on the best conceptual approach to editing feature attributes
> and could really use some feedback or other ideas. In part because I
> think I'm too tangled in all the code parts and have lost the big picture.
>
> So at a high level I need:
>
> 1) base map - check works fine
> 2) vector layer pulling data from server - check works fine
> 3) toolbar with [Nav][createPOI][dragPOI][selectPOI] - check have this
> but might need to rethink it
> 4) [createPOI]
>    a) needs to take click on map - check, works fine
>    b) open popup to allow setting attribute, check have this but ...
>    c) have [cancel] to abort creation - have button but how to abort

for a new feature "cancel" should just destroy that feature.

for an updated feature "cancel" should go back to the initial feature,
cloning the feature prior modification may help.

>    d) have [save] to write the data to the server - have button but how
> to save

If you use a protocol you can use protocol.create([feature]) or
protocol.commit([featute]). I'm not sure I'm answering your
question...

>    e) update layer with new feature - not sure the best way to do this.

what do you mean?

>      1) get return gid from server, add it to feature, and feature to layer

I'd recommend you look at the Strategy.Save code.

>      2) destroy the temporary feature, and have server return a complete
> feature that gets added to layer
>      3) not sure how to hook either of these into the code
> 5) [dragPOI] - check works, needs a myXML writer I think
> 6) [selectPOI] - check, have this but not everything works
>    a) open popup to allow editing attributes - check have this, but ...
>    b) have [delete] which will delete the feature
>    c) have [cancel] which will cancel the edits
>    d) have [save] which will save the edits to the server
>    e) update the layer with the modified feature - again see [createPOI]
>
> So where I'm getting caught up is that in form button onClick function
> you really do not know what feature you are dealing with

Hmm... when do you open the popup? I'd say when a new feature is drawn
on the map and when a feature is selected for modification. So when
you have an open popup you know the feature you are dealing with, no?

> so I guess that
> means that the selected feature needs to be listening for events
> "abort", "cancel" and "save" that correspond to the buttons. and all the
> function should try to do is trigger the appropriate event. And that the
> listener should also have the responsibility for closing the popup.
>
> 1) So where should the listener be attached, I suppose to the vector
> layer as Alexandre suggested in earlier email, but that did compute yet.
>
> 2) thoughts on best practice for updating the modified features?

Sorry I don't understand this question?

Cheers,

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemo...@camptocamp.com
http://www.camptocamp.com
___
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users