Re: problem with two key ranges in couchdb
On 3 Jan 2010, at 14:57, Duane Almond Sto. Tomas wrote: Is there other way? because geocouch does not support PHP language and PHP will be the language of my project. GeoCouch lives behind CouchDB. You can access it using PHP through CouchDB just fine. Cheers Jan -- On Sat, Jan 2, 2010 at 10:22 AM, Chris Anderson jch...@apache.org wrote: On Sat, Jan 2, 2010 at 5:41 AM, Duane Almond Sto. Tomas dua...@gmail.com wrote: I'm having problem getting the right results in my coordinate system. To explain my system, I have this simple database that have x_axis, y_axis and name columns. I don't need to get all the data, I just need to display some part of it. The fundamental problem is that CouchDB indexes are 1-dimensional. Essentially a sorted list. You can pull out every point between 2 lines of longitude. You can pull out every point between 2 lines of latitude. But when you need points within a bounding box, you have to pull out all of the above, and intersect them in your application. (There are some optimizations you do, but fundamentally, this is the issue.) This general problem is addressed with geo indexers. You might want to take a look at this one for Couch: http://vmx.cx/cgi-bin/blog/index.cgi/geocouch-new-release-0.10.0:2009-09-19:en,CouchDB,Python,geo Chris For example, I have a coordinate system that have 10:10(meaning from x_axis -10 to 10 and from y_axis -10 to 10) and I want to display only 49 coordinates. In sql query I can do it something like this: select * from coordinate where x_axis = -3 and x_axis = 3 and y_axis = -3 y_axis = 3 I tried this function but no success: by_range: { map: function(doc) { emit([doc.x_axis, doc.y_axis], doc) } } by_range?startkey=[-3,-3]endkey=[3,3] I got a wrong results of: -3x-3 -3x-2 -3x-1 -3x0 -3x1 -3x2 -3x3 -- should not display this part -- -3x4 -3x5 -3x6 -3x7 -3x8 -3x9 -3x10 -- end of should not display this part -- . up to 3x3 to give you a better understanding of my project here is the screenshot of that I want to be made: http://img96.imageshack.us/img96/5382/coordinates.jpg -- I wanted a perfect ending. Now I've learned, the hard way, that some poems don't rhyme, and some stories don't have a clear beginning, middle, and end. Life is about not knowing, having to change, taking the moment and making the best of it, without knowing what's going to happen next..Farewell Team ! Duane Almond C. Sto. Tomas 09062772487 OOiP Manila personal websites: http://duasto.freehostia.com/ http://duanealmond.com/ -- Chris Anderson http://jchrisa.net http://couch.io -- I wanted a perfect ending. Now I've learned, the hard way, that some poems don't rhyme, and some stories don't have a clear beginning, middle, and end. Life is about not knowing, having to change, taking the moment and making the best of it, without knowing what's going to happen next..Farewell Team ! Duane Almond C. Sto. Tomas 09062772487 OOiP Manila personal websites: http://duasto.freehostia.com/ http://duanealmond.com/
Re: problem with two key ranges in couchdb
Is there other way? because geocouch does not support PHP language and PHP will be the language of my project. On Sat, Jan 2, 2010 at 10:22 AM, Chris Anderson jch...@apache.org wrote: On Sat, Jan 2, 2010 at 5:41 AM, Duane Almond Sto. Tomas dua...@gmail.com wrote: I'm having problem getting the right results in my coordinate system. To explain my system, I have this simple database that have x_axis, y_axis and name columns. I don't need to get all the data, I just need to display some part of it. The fundamental problem is that CouchDB indexes are 1-dimensional. Essentially a sorted list. You can pull out every point between 2 lines of longitude. You can pull out every point between 2 lines of latitude. But when you need points within a bounding box, you have to pull out all of the above, and intersect them in your application. (There are some optimizations you do, but fundamentally, this is the issue.) This general problem is addressed with geo indexers. You might want to take a look at this one for Couch: http://vmx.cx/cgi-bin/blog/index.cgi/geocouch-new-release-0.10.0:2009-09-19:en,CouchDB,Python,geo Chris For example, I have a coordinate system that have 10:10(meaning from x_axis -10 to 10 and from y_axis -10 to 10) and I want to display only 49 coordinates. In sql query I can do it something like this: select * from coordinate where x_axis = -3 and x_axis = 3 and y_axis = -3 y_axis = 3 I tried this function but no success: by_range: { map: function(doc) { emit([doc.x_axis, doc.y_axis], doc) } } by_range?startkey=[-3,-3]endkey=[3,3] I got a wrong results of: -3x-3 -3x-2 -3x-1 -3x0 -3x1 -3x2 -3x3 -- should not display this part -- -3x4 -3x5 -3x6 -3x7 -3x8 -3x9 -3x10 -- end of should not display this part -- . up to 3x3 to give you a better understanding of my project here is the screenshot of that I want to be made: http://img96.imageshack.us/img96/5382/coordinates.jpg -- I wanted a perfect ending. Now I've learned, the hard way, that some poems don't rhyme, and some stories don't have a clear beginning, middle, and end. Life is about not knowing, having to change, taking the moment and making the best of it, without knowing what's going to happen next..Farewell Team ! Duane Almond C. Sto. Tomas 09062772487 OOiP Manila personal websites: http://duasto.freehostia.com/ http://duanealmond.com/ -- Chris Anderson http://jchrisa.net http://couch.io -- I wanted a perfect ending. Now I've learned, the hard way, that some poems don't rhyme, and some stories don't have a clear beginning, middle, and end. Life is about not knowing, having to change, taking the moment and making the best of it, without knowing what's going to happen next..Farewell Team ! Duane Almond C. Sto. Tomas 09062772487 OOiP Manila personal websites: http://duasto.freehostia.com/ http://duanealmond.com/
Re: problem with two key ranges in couchdb
Hey Duane, On Sun, Jan 3, 2010 at 2:57 PM, Duane Almond Sto. Tomas dua...@gmail.com wrote: Is there other way? because geocouch does not support PHP language and PHP will be the language of my project. There's a view server written in PHP, it's part of the Sopha (a CouchDB access wrapper): http://github.com/shevron/sopha I haven't tried it yet, but it might give you something to play with/extend. Till On Sat, Jan 2, 2010 at 10:22 AM, Chris Anderson jch...@apache.org wrote: On Sat, Jan 2, 2010 at 5:41 AM, Duane Almond Sto. Tomas dua...@gmail.com wrote: I'm having problem getting the right results in my coordinate system. To explain my system, I have this simple database that have x_axis, y_axis and name columns. I don't need to get all the data, I just need to display some part of it. The fundamental problem is that CouchDB indexes are 1-dimensional. Essentially a sorted list. You can pull out every point between 2 lines of longitude. You can pull out every point between 2 lines of latitude. But when you need points within a bounding box, you have to pull out all of the above, and intersect them in your application. (There are some optimizations you do, but fundamentally, this is the issue.) This general problem is addressed with geo indexers. You might want to take a look at this one for Couch: http://vmx.cx/cgi-bin/blog/index.cgi/geocouch-new-release-0.10.0:2009-09-19:en,CouchDB,Python,geo Chris For example, I have a coordinate system that have 10:10(meaning from x_axis -10 to 10 and from y_axis -10 to 10) and I want to display only 49 coordinates. In sql query I can do it something like this: select * from coordinate where x_axis = -3 and x_axis = 3 and y_axis = -3 y_axis = 3 I tried this function but no success: by_range: { map: function(doc) { emit([doc.x_axis, doc.y_axis], doc) } } by_range?startkey=[-3,-3]endkey=[3,3] I got a wrong results of: -3x-3 -3x-2 -3x-1 -3x0 -3x1 -3x2 -3x3 -- should not display this part -- -3x4 -3x5 -3x6 -3x7 -3x8 -3x9 -3x10 -- end of should not display this part -- . up to 3x3 to give you a better understanding of my project here is the screenshot of that I want to be made: http://img96.imageshack.us/img96/5382/coordinates.jpg -- I wanted a perfect ending. Now I've learned, the hard way, that some poems don't rhyme, and some stories don't have a clear beginning, middle, and end. Life is about not knowing, having to change, taking the moment and making the best of it, without knowing what's going to happen next..Farewell Team ! Duane Almond C. Sto. Tomas 09062772487 OOiP Manila personal websites: http://duasto.freehostia.com/ http://duanealmond.com/ -- Chris Anderson http://jchrisa.net http://couch.io -- I wanted a perfect ending. Now I've learned, the hard way, that some poems don't rhyme, and some stories don't have a clear beginning, middle, and end. Life is about not knowing, having to change, taking the moment and making the best of it, without knowing what's going to happen next..Farewell Team ! Duane Almond C. Sto. Tomas 09062772487 OOiP Manila personal websites: http://duasto.freehostia.com/ http://duanealmond.com/
Re: problem with two key ranges in couchdb
On Sat, Jan 2, 2010 at 5:41 AM, Duane Almond Sto. Tomas dua...@gmail.com wrote: I'm having problem getting the right results in my coordinate system. To explain my system, I have this simple database that have x_axis, y_axis and name columns. I don't need to get all the data, I just need to display some part of it. The fundamental problem is that CouchDB indexes are 1-dimensional. Essentially a sorted list. You can pull out every point between 2 lines of longitude. You can pull out every point between 2 lines of latitude. But when you need points within a bounding box, you have to pull out all of the above, and intersect them in your application. (There are some optimizations you do, but fundamentally, this is the issue.) This general problem is addressed with geo indexers. You might want to take a look at this one for Couch: http://vmx.cx/cgi-bin/blog/index.cgi/geocouch-new-release-0.10.0:2009-09-19:en,CouchDB,Python,geo Chris For example, I have a coordinate system that have 10:10(meaning from x_axis -10 to 10 and from y_axis -10 to 10) and I want to display only 49 coordinates. In sql query I can do it something like this: select * from coordinate where x_axis = -3 and x_axis = 3 and y_axis = -3 y_axis = 3 I tried this function but no success: by_range: { map: function(doc) { emit([doc.x_axis, doc.y_axis], doc) } } by_range?startkey=[-3,-3]endkey=[3,3] I got a wrong results of: -3x-3 -3x-2 -3x-1 -3x0 -3x1 -3x2 -3x3 -- should not display this part -- -3x4 -3x5 -3x6 -3x7 -3x8 -3x9 -3x10 -- end of should not display this part -- . up to 3x3 to give you a better understanding of my project here is the screenshot of that I want to be made: http://img96.imageshack.us/img96/5382/coordinates.jpg -- I wanted a perfect ending. Now I've learned, the hard way, that some poems don't rhyme, and some stories don't have a clear beginning, middle, and end. Life is about not knowing, having to change, taking the moment and making the best of it, without knowing what's going to happen next..Farewell Team ! Duane Almond C. Sto. Tomas 09062772487 OOiP Manila personal websites: http://duasto.freehostia.com/ http://duanealmond.com/ -- Chris Anderson http://jchrisa.net http://couch.io