Data types for Latitude/Longitude on Doctrine 2 with YAML

NameI’m a devote Doctrine 1.2 user but times are changing and now I’m faced with the challenge of learning and updating all of my applications to use the brand new Doctrine 2.2 framework.

Doctrine 2.2 has been completely renewed and a lot of cool stuff from Doctrine 1.2 has dissapeared, one that will be missed the most I’m sure is the auto-magic the behaviours provided, this said some new challeneges arise, for example, what type of data to use to store basic data like latitud and longitud since the Geographical behaviour is now gone.

A solution I’ve find is to use decimal type of data with a size of 18,12, so if you are defining your models with YAML like I do you can do the following:

 

 

Entities\City:
  type: entity
  fields:
    id:
      type: integer
      id: true
      generator:
        strategy: AUTO      
    name:
      type: string(255)
    latitude:
      type: decimal(18)
      scale: 12
      precision: 18
      nullable: true
    longitude:
      type: decimal(18)
      scale: 12
      precision: 18
      nullable: true

With this type of data I fixed my need of storing latitude and longitud data.

VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)
Clip to Evernote

One thought on “Data types for Latitude/Longitude on Doctrine 2 with YAML

  1. Your v speaks before everything else and it matters a lot at workplace. You befitting someone or make a transit by casually, and the first thing that they observation is what you are wearing. The impression that you make with your align influences the way in which you are evaluated as an employee.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>