Nothing Special   »   [go: up one dir, main page]

Datatype To Store Longitude/Latitude in Mysql: Únete A La Comunidad de Stack Overflow

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

20/3/2017 floatingpointDatatypetoStoreLongitude/LatitudeinMysqlStackOverflow

xDismiss

netealacomunidaddeStackOverflow

Stack Overflow es una comunidad de 6.9 millones


de programadores como t que se ayudan
mutuamente.
nete a ellos, slo te llevar un minuto:

Registrarse

DatatypetoStoreLongitude/LatitudeinMysql

'43.005895','71.013202'

Tryingtouse:

INSERTINTOtable(fanDetLocZip,fanDetLocCity,fanDetLocState,fanDetLocLat,
fanDetLocLong,fanDetLocTZ,fanDetLocDST)
VALUES(00210,'Portsmouth','NH','43.005895','71.013202',5,1);

I'mcurrentlyusingthedatatype SPATIAL , GEOMETRY .

Itsgivingmeerrorslike:

CannotgetgeometryobjectfromdatayousendtotheGEOMETRYfield

Allthevalueshave2digits,and6decimalplacesafterdecimal.HowdoIstorethisinmysql?

ErrorIgetwhenIuse:
INSERTINTOTable(fanDetLocZip,fanDetLocCity,fanDetLocState,fanDetLocLatLong,fanDetLocTZ,
fanDetLocDST)

VALUES(00210,'Portsmouth','NH',point(43.005895,71.013202),5,1)

ErrorImage:

mysql floatingpoint geospatial sqldatatypes

editedFeb10'14at6:04 askedMar5'12at0:11
S1LENTWARRIOR CodeTalk
3,613 3 24 41 1,534 6 27 61

Canyouaddthetable'sdefinition( CREATE statement)?Whichcolumnisoftype GEOMETRY ? ypercube


Mar5'12at0:19

fanDetLocLat,fanDetLocLong CodeTalk Mar5'12at0:20

That'stwocolumns.DoyouhaveacolumnoftypeGEOMETRYorPOINT? ypercube Mar5'12at0:22

YES,ThosetwoaretypeGEOMETRY CodeTalk Mar5'12at0:33

Pleasepostthecreateordescribetable?Itdoesn'tmakesensetogiveadvicewithoutit. MichaelDurrant
Mar5'12at0:33

2Answers

http://stackoverflow.com/questions/9560147/datatypetostorelongitudelatitudeinmysql 1/2
20/3/2017 floatingpointDatatypetoStoreLongitude/LatitudeinMysqlStackOverflow
Noencuentraslarespuesta?PreguntaenStackOverflowenespaol.

Youcanuse POINT() tostoreintoacolumnoftype GEOMETRY or POINT :

POINT(43.005895,71.013202)

IftheGeometrycolumnisnamed geom ,youcanusethis:

INSERTINTOtable
(...,geom,...)
VALUES
(...,POINT(43.005895,71.013202),...)

Ifyouwanttoshowdatastored,youcanusethe X() and Y() functions:

SELECTX(geom)ASx,Y(geom)ASy
FROMtable

editedDec13'12at12:05 answeredMar5'12at0:24
AhmedelGendy ypercube
188 4 13 81.2k 9 100 170

Thisishelpful,IamguessingIjustdidntaddpoint().Neverhaveusedgeometryvaluesbefore.Thanks
ypercube! CodeTalk Mar5'12at0:34

WhenIuse:INSERTINTOTable(fanDetLocZip,
fanDetLocCity,fanDetLocState,fanDetLocLatLong,fanDetLocTZ,fanDetLocDST)
VALUES(00210,'Portsmouth','NH',point(43.005895,71.013202),5,1)itinputsthevalueweird.See
screenshotabove. CodeTalk Mar5'12at0:38

@user975947:Seemyeditabove. ypercube Mar5'12at0:45

Weird,well,thatatleastworks.Maybeitsabrowserbugorsomething.ThanksYPerCube! CodeTalk
Mar5'12at0:57

3 Shouldn'tbethePOINTbePOINT(43.00589571.013202)asdescribedhere?
dev.mysql.com/doc/refman/5.0/en/giswktformat.htmlnolazybits Oct12'12at10:06

WhydontyouuseinsteadaFloattypeforyourlat/long?

Float(10,6)

answeredMar5'12at0:30
KevinFauver
186 1 5 14

3 floatisnotgoodtostorelattitudeandlongtitude.Doubleisthebestdatatypetostorelattitude/longtitude.
ReadCompleteDiscussionArunRajFeb27'14at9:28

http://stackoverflow.com/questions/9560147/datatypetostorelongitudelatitudeinmysql 2/2

You might also like