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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

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

swethaRamagoni
7-Bedrock

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

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

 

Thanks, Adam

Top Tags