cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Regular Member

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

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 2

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

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

 

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

Thanks, Adam

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum!