Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 286281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:37:20+00:00 2026-05-12T05:37:20+00:00

There have been a decent amount of questions about mysql spatial datatypes, however mine

  • 0

There have been a decent amount of questions about mysql spatial datatypes, however mine is more specific to how best to deal with them within a rails MVC architecture.

I have an input form where an admin user can create a new point of interest, let’s say, a restaurant and input some information. They can also input a human-readable latitude and longitude in decimal format.

However, for distance calculations, etc… I am storing the location data as a spatial point in the database.

My question therefore, is how to best handle this in the MVC architecture in rails?

Here are some ideas I had, but nothing really seems clean:

  • Call :after_filter method that takes the new instance of the object and does a raw SQL update that handles the “GeomFromText(‘POINT(lat long)’ ))” goodness. The issue with this is that “lat/long” would be text fields in my create form, although this disrupts the clean form_for :object architecture that rails provides since lat/long aren’t really attributes, they’re just there to let a human input values that aren’t mysql spatials.

  • Maybe creating a trigger in the db to run after a row insert that updates that row? I have no idea and it doesn’t seem like these triggers would have access to the lat/long, unless I stored the lat/long as well as the spatial point, and then created the row in the db with the lat/long decimals, and then ran the trigger after creation to update the spatial. I guess i could also do that with an after_filter if I added the lat/long columns to the model.

Any other ideas? I think storing the lat/long is redundant since I’ll really be using the spatial point for distance calculations, etc… but it might be necessary if I’m allowing for human editing.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T05:37:21+00:00Added an answer on May 12, 2026 at 5:37 am

    Check out the geokit-rails plugin for Rails which does distance calculations using plain lat/lng columns as floats (and uses the geokit gem). However, if you’d like to use your database’s geo-spatial abilities, GeoRuby supports the basic spatial features like Point or LineString as column types. I hope these help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There have been several questions posted to SO about floating-point representation. For example, the
There have been several questions over the past few days about the proper use
There have been a few similar questions with solutions, but none answered my question,
There have been many debates about this topic already here, but none of them
There have been questions with answers on how to write rubygems, but what should
There have been some similar questions asked regarding Grid views, but none have been
There have been proposals for C++ delegates which have lower overhead than boost::function :
There have been a couple of threads on this topic in the past that
There have been a number of problems related to IE8 breaking Visual Studio 2005/2008.
There have been multiple discussions on this topic in the site but I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.