Skip to main content
1-Visitor
May 13, 2018
Question

Is there a way to change string to Location data type ?

  • May 13, 2018
  • 2 replies
  • 1808 views

Hi All,

I am getting Lat and Long of a plant location  from Database which are of VARCHAR . I am trying to convert them to Location datatype in Thingworx, but getting following error.

 

Unable To Convert From java.lang.String to LOCATION

 

Can someone help me on this ?

 

 

2 replies

15-Moonstone
May 14, 2018

Hi,

 

Location is a little bit more complex base type. It is actualy a JSON with 4 Objects:

  • latitude
  • longitude
  • elevation
  • units

Like this:

{
 "location": {
 "latitude": 0.1111,
 "longitude": 0.2222,
 "elevation": 0.3333,
 "units": "WGS84"
 }
}

So iff you want to change its value in ThingWorx JS code you should create new Location property and assing value like it would be a JSON:

 

me.myLocationProperty = { 
 "latitude": 50,
 "longitude": 50,
 "elevation": 50
}

You can now change 50, 50 & 50 hardcoded values to your paramaters from VARCHAR.

 

Best,

Adam

 

1-Visitor
May 16, 2018

Thanks, Adam