Closed akosmaroy closed 8 years ago
Did anyone ever succeed in using GeoPouch in a browser? I also still am not able to get it running?
I did succeed in using GeoPouch in a browser-like environment, but that's quite a long time ago. No idea if it would still work. Anyway, I used browserify, and this pretty much was my source file: https://git.launchpad.net/python-pouchdb/tree/js/python-pouchdb-js/index.js#n52 .
As for querying, did you look at the test suite for examples? https://github.com/pouchdb/geopouch/blob/master/test/test.js
Hope that helps.
Thanks for the hints!
I'm not even getting to the query part, since the geopouch library does not even attach to any PouchDB database. I'm able to call a "geopouch" object at the root level.
I tried browserify and webpack on the dist-version and on the source version. If I use these versions, already the PouchDB.plugin('Spatial',geopouch);
command fails.
Sadly, I'm far from being an expert with browserify and the likes of ...
if you include the dist version via a script tag that would be when you'd then do PouchDB.plugin('Spatial',geopouch);
The suspicious thing for me is, that the call PouchDB.plugin('Spatial',gepouch);
does return a function.
To clearly state my proceeding:
My HTML file looks like this:
To visualize the feedback, I excluded any scripts from this code but entered them in the JS console of the browser:
When I do not use the downloaded version of geopouch, but a browserified one, a message after the command PouchDB.plugin('Spatial',gepouch);
is displayed, saying Uncaught ReferenceError: geopouch is not defined(…)'
.
I hope this is not due to some misunderstanding or technical shortcoming on my part ... ? Or better: I hope it is! :-)
sorry, the syntax should actually be PouchDB.plugin(geopouch)
This works, the library is loaded and attached to any PouchDB ! :-D But.... while the same query produces results on a CouchDB via its native HTTP API, it does not give any results via PouchDB. Neither on the replicated version of the CouchDB nor on the CouchDB accessed by the PouchDB interface. The query and result via PouchDB look like this:
Using the rtree branch makes no difference.
The results via the CouchDB API look like this:
@scubbx Try [[0, 180], [0, 90]]
instead.
haha Right!
But nontheless:
docdb
is the CouchDB via PouchDB interface, localdocdb
is the replicated version.
Both databases are filled:
ok this is a different error, can you post graph/roads?
I took a screenshot, since it has nice code-highliting:
Except for the design document, all documents have the entrytype
property set to link
.
One typical document looks like this:
can you add a catch(function (err){console.log(err)})
to the end of the chain?
This does not give more information. Did I use it correctly?
instead of {limit: 5}, function (resul...
you should do {limit: 5}).then(function(resul...
also limit isn't a supported option
localdocdb.spatial('graph/roads', [[0, 180], [0, 90]]).then( function(resul){console.log(resul);} ).catch(function (err){console.log(err)});
and the same on docdb.spatial
did not change anything.
it looks like there are 2 errors that top one of the property '0' of undefined, does that have a stack trace?
This one?
ahaha looks like an invalid geometry, try doing pause on uncaught exception (or caught if that doesn't catch anything)
Hi,
i also tried to get some geojson features out of the pouchdb. geopouch is working, but i cannot get the features out of it. I use coudb (without spatial) to store the docs and then replicate to pouch with spatial plugin. I use:
evt_db.spatial(function (doc) {emit(doc.geometry);}, [0, 180, 0, 90]).then(function(result){ console.log(result)}).catch(function (err){console.log(err)});
but receive:
Possibly unhandled Error. can't delete it if there is nothing in the tree geopouch.js (Zeile 171 a typical feature looks like that:
What am i doing wrong? are the features defined correctly?
ok I think there might be a bug related to replication and or error catching, I will investigate further
Hi, thx for keeping in touch. I broke it down to the following. If i load two json files directly into pouchdb (via bulkDocs() it works, but only for the very first time. afterwards it does not work until i delete the database manually. `evt_db.bulkDocs([{ "_id" : "eb46c0cc24eabb6427af7eac2b0012ac", "geometry" : { "type" : "Point", "coordinates" : [13.3971420055456, 52.5296601136334] } }, { "_id" : "eb46c0cc24eabb6427af7eac2b001c9f", "geometry" : { "type" : "Point", "coordinates" : [13.6384082053328, 52.418740058446] } }]);
//evt_db.replicate.from(evt_remoteCouch);
evt_db.spatial( function(doc){ emit(doc.geometry);} , [[13.3971420055456,52.418740058446],[13.6384082053328,52.5296601136334]]).then(function(resp) { resp.length.should.equal(2); console.log(resp); var nr = resp.map(function(i) { console.log(i); return i.properties; }); nr.sort(); }).catch(function(err) { console.log(err) });` The result is: Reloading the page produces the following message (if i comment out the bulkDocs(), since everything should be inside Pouch):
Any ideas or hints? i am not specialist in Javascript, but i need some help. Also i just get back the id. How can i get the properties of my json objects? because emit just allows to give back the geometry property.
THX in advance for any advice ot help
ok I'll look into it when I get a chance
ok figured it out, there was something wonky in how i was handling temp views, temp ones should now actually be temp in version 2.0.1
closing this issue as it somewhat meandered into something new, if there are still problems with the indexing lets start a new issue
thus, is there a complete, browser based example somewhere? :)
no but we went over all of your questions in this thread I'm pretty sure, if there are things still stumping you ...
Thank you for the hints! The examples given on the GeoCouch repository description are working, my big database is not. I will report back when I found the problem.
@akosmaroy any luck finding an example ?
@ryadiv nope :(
I wonder if there is a complete, browser based example on how tou use GeoPouch, that would demonstrate: