DataMapper Geokit

42 views
Skip to first unread message

Mike S

unread,
Aug 30, 2010, 4:00:43 PM8/30/10
to DataMapper
I am currently working on a sinatra app using datamapper and I would
like to use the geokit gem. The last time anyone touched the geokit
gem was about a year ago and it is still using datamapper version
0.10.2. I have been trying to get it up and running on dm 1.0.0. I
kept getting 3 for 2 arguement errors on the
property_to_column_name_with_distance method and deleted the qualifer
variable that was getting passed in and that fixed that issue. Now on
my login, the login works fine until after authenticating the user I
try to grab the ID. Then I get this error undefined method `field' for
#<DataMapper::Query::Operator @target=:all @operator=:count>.
It appears to be a conflict with the adapter.rb file in datamapper.

Does anyone know anything about this error or geokit that could help
me out a bit?

Matt King

unread,
Aug 30, 2010, 7:17:46 PM8/30/10
to datam...@googlegroups.com
On 30 August 2010 13:00, Mike S <mskw...@purdue.edu> wrote:
I am currently working on a sinatra app using datamapper and I would
like to use the geokit gem. The last time anyone touched the geokit
gem was about a year ago and it is still using datamapper version
0.10.2. I have been trying to get it up and running on dm 1.0.0. I
kept getting 3 for 2 arguement errors on the
property_to_column_name_with_distance method and deleted the qualifer
variable that was getting passed in and that fixed that issue. Now on
my login, the login works fine until after authenticating the user I
try to grab the ID. Then I get this error undefined method `field' for
#<DataMapper::Query::Operator @target=:all @operator=:count>.
It appears to be a conflict with the adapter.rb file in datamapper.


Hi Mike,

I maintain dm-geokit, and I believe I got your pull request on github the other day, but haven't had a chance to do an update...obviously it needs to be updated to work with dm-core-1.0.0. I'm hoping to get to it this week, if you can wait...

Cheers,

Mike S

unread,
Aug 31, 2010, 12:09:31 AM8/31/10
to DataMapper
I don't mind waiting, but I didn't do much more that update that
rakefile/gemspec in order to get the gems to stop throwing version
errors. Once I got the gems working together, I kept getting errors on
the property_to_column_name_without_distance method in resource.rb. (3
of 2 Arguements). After changing
property_to_column_name_without_distance(property, qualify, qualifier)
to property_to_column_name_without_distance(property, qualify) the
error disappeared. But when logging in I'm getting this error.

undefined method `field' for
#<DataMapper::Query::Operator @target=:all @operator=:count>

in adapter.rb which is part of the datamapper stuff.

Unfortunately, I don't really know what I'm doing and just trying to
hack things together at this point to get something working. Enjoy
help from you would be appreciated.


On Aug 30, 6:17 pm, Matt King <swd...@gmail.com> wrote:
Message has been deleted

mskw...@purdue.edu

unread,
Sep 1, 2010, 1:07:48 AM9/1/10
to datam...@googlegroups.com
I fixed the issue I was having. The only thing at the moment I can't seem to get
working is the has_geographic_location on my models. It always throws a boot
error. Could you possibly write some documentation for dm-geokit as there seems
to be none at the moment.

Quoting Mike S <mskw...@purdue.edu>:

> --
> You received this message because you are subscribed to the Google Groups
> "DataMapper" group.
> To post to this group, send email to datam...@googlegroups.com.
> To unsubscribe from this group, send email to
> datamapper+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/datamapper?hl=en.
>
>


Mike S

unread,
Sep 22, 2010, 5:43:19 PM9/22/10
to DataMapper
Have you worked on this at all Matt? I still can't get
has_geographic_address working.

Matt King

unread,
Sep 23, 2010, 8:51:12 PM9/23/10
to datam...@googlegroups.com
Hi all,

Thanks to some help on #datamapper from dkubb and others, I've gotten dm-geokit compatible with dm-core-1.0.2. The only spec I can't get to currently pass in searching for locations while also filtering on an association...for example:

Location.all(:address.near => {:origin => "portland, or", :distance => 1.mi}, "category.name" => "Example Category")

will not currently work.

Talking with some folks on #datamapper, I think I'm going to re-tool how some of the internals work. But for now at least (most) of the expected functionality works with dm-core-1.0.2.

dm-geokit now depends some more gems, since functionality was split off into separate gems starting with dm-core-1.0:

dm-is-versioned
dm-migrations

I'm debating whether to keep these in or not, I'm leaning towards taking them out and letting users upgrade/migrate their schemas as needed.

Anyway, you should now be able to gem install dm-geokit and get the latest version. You can also check the source at http://github.com/mattking17/dm-geokit

-Matt

On 22 September 2010 14:43, Mike S <mskw...@purdue.edu> wrote:
Have you worked on this at all Matt? I still can't get
has_geographic_address working.
--
You received this message because you are subscribed to the Google Groups "DataMapper" group.
To post to this group, send email to datam...@googlegroups.com.
To unsubscribe from this group, send email to datamapper+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.




--
Matt King
ma...@mattking.org

Dominic Sisneros

unread,
Sep 24, 2010, 4:22:42 AM9/24/10
to datam...@googlegroups.com
has anyone worked on something like spatial_adapter for dataobjects and datamapper?  This would allow us to use PostGIS or spatiallite to do the distance calculations


arbales

unread,
Sep 24, 2010, 6:09:17 PM9/24/10
to DataMapper
I'm not sure what you mean by splitting of dm-migrations.
I, personally, see no reason why there should be an
enforced dependency on migrations or versioned, but I do
think being able to auto_upgrade is important. I use it for
development, and even occasionally for production.




On Sep 23, 5:51 pm, Matt King <swd...@gmail.com> wrote:
> Hi all,
>
> Thanks to some help on #datamapper from dkubb and others, I've gotten
> dm-geokit compatible with dm-core-1.0.2. The only spec I can't get to
> currently pass in searching for locations while also filtering on an
> association...for example:
>
> Location.all(:address.near => {:origin => "portland, or", :distance =>
> 1.mi}, "category.name" => "Example Category")
>
> will not currently work.
>
> Talking with some folks on #datamapper, I think I'm going to re-tool how
> some of the internals work. But for now at least (most) of the expected
> functionality works with dm-core-1.0.2.
>
> dm-geokit now depends some more gems, since functionality was split off into
> separate gems starting with dm-core-1.0:
>
> dm-is-versioned
> dm-migrations
>
> I'm debating whether to keep these in or not, I'm leaning towards taking
> them out and letting users upgrade/migrate their schemas as needed.
>
> Anyway, you should now be able to gem install dm-geokit and get the latest
> version. You can also check the source athttp://github.com/mattking17/dm-geokit
>
> -Matt
>
> On 22 September 2010 14:43, Mike S <mskwa...@purdue.edu> wrote:
>
> > Have you worked on this at all Matt? I still can't get
> > has_geographic_address working.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "DataMapper" group.
> > To post to this group, send email to datam...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > datamapper+...@googlegroups.com<datamapper%2Bunsubscribe@googlegrou ps.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/datamapper?hl=en.
>
> --
> Matt King
> m...@mattking.org

mskw...@purdue.edu

unread,
Sep 27, 2010, 10:53:37 AM9/27/10
to datam...@googlegroups.com
I've included the new version of you gem + dm-migrations and dm-is-versioned,
but I'm still getting errors whenever I try to add has_geographic_location to
any of my models. The error I am getting is:

DataMapper::RepositoryNotSetupError: Adapter not set: default. Did you forget to
setup?

Is this something you are aware is not currently working or is there something
on my end that is conflicting with the way dm-geokit is working?

Quoting arbales <arb...@gmail.com>:

> datamapper+...@googlegroups.com.

Matt King

unread,
Sep 27, 2010, 11:57:42 AM9/27/10
to datam...@googlegroups.com
On 27 September 2010 07:53, <mskw...@purdue.edu> wrote:
I've included the new version of you gem + dm-migrations and dm-is-versioned,
but I'm still getting errors whenever I try to add has_geographic_location to
any of my models. The error I am getting is:

DataMapper::RepositoryNotSetupError: Adapter not set: default. Did you forget to
setup?

Is this something you are aware is not currently working or is there something
on my end that is conflicting with the way dm-geokit is working?

I did realize that I put in an option on defining the geographic property that made it stop failing when dm-validations is included, however now it fails when dm-validations *isn't* included. :-P

Can you try including dm-validations as well? Also, if you check the spec directory in spec_helper.rb there are definitions that all pass. You may double check what you're doing vs. what's in the spec.

-Matt

mskw...@purdue.edu

unread,
Sep 27, 2010, 2:55:00 PM9/27/10
to datam...@googlegroups.com
I tried making a completely new model called locations that doesn't interact
with my application at all. Whenever I put in has_geographic_location I'm still
getting the same error even with dm-validations included.

I can currently do most things. Instead of using has_geographic_location I'm
just using

newAddress = Geokit::Geocoders::YahooGeocoder.geocode "#{address.address},
#{address.city} #{address.state}, #{address.zip}"

and then running an .each loop on all the addresses in my model using a
newAddress2 = Geokit::Geocoders::YahooGeocoder.geocode "#{address.address},
#{address.city} #{address.state}, #{address.zip}"

then setting
dis = newAddress.distance_to(newAddress2)
if dis <= 10
//do some code
end

It works, but I'm assuming it's slower than the current method and might have
problems as the site scales.


Quoting Matt King <swd...@gmail.com>:

Reply all
Reply to author
Forward
0 new messages