What's new

Welcome to the GSA Community!

This is the Official User Community for GE's GeoSpatial Analysis products. By registering with us, you'll be able to discuss, share and private message with other members of our Community.
Registration is currently only allowed with a personalized invitation code, which you might have received previously. If you haven't got one:
please get in touch with your GE contact person or your regional moderator(s): see FAQ.

SignUp Now!

How to Convert Resulttyp system.decimal[] into string / integer (GSA Pro 5.2.5)

Björn Schaefer

Member
Confirmed GSA Customer
Joined
Oct 26, 2020
Messages
91
Hi

within an analyticsobject I configured some additional fields like this:
1609924484079.png

The results are shown as {result}, but I need this as interger or string, without leading / ending brackets.

Normally, the following step works:
Create another Expression Object based on the AO shown above like this:
1609924820924.png

Unfortunately the result "string" is system.Decimal[] and not (as expected) "{2618880}" , so that there is no further option to edit with replace("{","") to delete the brackets

Anyone ideas how to manage this?
 

Frank Pistorius

Spatial Eye
Confirmed GSA Customer
Joined
May 26, 2020
Messages
36
Hi Björn,

As far as I can tell, there currently is no way of doing this.

As you indicate, the ToString() method on a vector should return a string holding the individual items in the array.

I suggest logging an enhancement/bug with your support channel to have this addressed.

Regards,

Frank
 

Björn Schaefer

Member
Confirmed GSA Customer
Joined
Oct 26, 2020
Messages
91
Thanks a lot for your support, I will do so...
In the meanwhile 1'll create a workaround by copying the systemid to string within the business-objekt, I guess, that will work...
 

peterschmidt

Spatial Eye - Moderator
Confirmed GSA Customer
Joined
Apr 16, 2020
Messages
2
Hi Björn,

To add to Frank's response: Using .ToString() on a vector will always return the type of vector (ie. Decimal[] or String[]), not the contents of that vector.

However, in the example you provide you seem to always have one element. Perhaps getting the first item from the vector and calling ToString() on that would give you the results you need.

As an example, take a look at this analysis collection I've created:
Screenshot 2021-01-06 154451.png

The table used as base for this expression collection has a vector with integers called GatherField. In this expression collection I take the first element by using [0]. Do note that this will always only return the first element from the vector, or null if it's an empty vector!

I hope this can provide a possible alternative approach.

Regards,
Peter
 

Björn Schaefer

Member
Confirmed GSA Customer
Joined
Oct 26, 2020
Messages
91
Hi Björn,

To add to Frank's response: Using .ToString() on a vector will always return the type of vector (ie. Decimal[] or String[]), not the contents of that vector.

However, in the example you provide you seem to always have one element. Perhaps getting the first item from the vector and calling ToString() on that would give you the results you need.

As an example, take a look at this analysis collection I've created:
View attachment 84

The table used as base for this expression collection has a vector with integers called GatherField. In this expression collection I take the first element by using [0]. Do note that this will always only return the first element from the vector, or null if it's an empty vector!

I hope this can provide a possible alternative approach.

Regards,
Peter

Hi Peter
Thank you very much for this... never used gatherField before :)
Unfortunately it ist not sure, that there will be always just one element within this vector, i'm just validating this with the owner of the used datasource. Some data have more than one element, but maybe this is an error within the datasource...

I will keep your solution in mind and test it, if possible
 
Top