× Requests and support related to jBackend.

SobiPro GeoFields don't look right

More
7 years 8 months ago - 7 years 8 months ago #6027 by IanF
The _data field for SobiPro geomap-type fields doesn't look like geo coordinates.
How can I decode this ?

fields":[
{"name": "Name", "fid": "61", "nid": "field_name", "sid": "193",…},
{"name": "Address", "fid": "67", "nid": "field_address", "sid": "193",…},
{"name": "Category", "fid": "62", "nid": "field_category", "sid": "193",…},
{
"name": "POI location",
"fid": "63",
"nid": "field_poi_location",
"sid": "193",
"section": "181",
"lang": "en-GB",
"_data": "YToyOntzOjg6ImxhdGl0dWRlIjtkOjU0Ljg3OTA1OTg7czo5OiJsb25naXR1ZGUiO2Q6LTEuNTc1MjMyMzAwMDAwMDM4ODt9",
"_rawData": "YToyOntzOjg6ImxhdGl0dWRlIjtkOjU0Ljg3OTA1OTg7czo5OiJsb25naXR1ZGUiO2Q6LTEuNTc1MjMyMzAwMDAwMDM4ODt9",
"fieldType": "geomap",
"isFree": "1",
"position": "5"
Last edit: 7 years 8 months ago by IanF.

Please Log in or Create an account to join the conversation.

More
7 years 8 months ago - 7 years 8 months ago #6028 by IanF
Replied by IanF on topic SobiPro GeoFields don't look right
It's base64 encoded

Encoding.UTF8.GetString(Convert.FromBase64String(field_poi_location)) will decode it to

a:2:{s:8:\"latitude\";d:54.8790598;s:9:\"longitude\";d:-1.5752323000000388;}

Not sure what this format is. Anyone know?
Last edit: 7 years 8 months ago by IanF.

Please Log in or Create an account to join the conversation.

More
7 years 8 months ago #6029 by IanF
Replied by IanF on topic SobiPro GeoFields don't look right
I've created a C# class to automatically handle decoding automatically. May be helpful to someone

[Serializable]
public class Field
{
public string name { get; set; }
public int fid { get; set; }
public string nid { get; set; }
public int sid { get; set; }
public int section { get; set; }
public string lang { get; set; }
public string _data { get; set; }

/// <summary>
/// Automatically decodes base64 data
/// </summary>
public string value
{
get
{
if (this.fieldType == "image" || this.fieldType == "category" || this.fieldType == "geomap")
{
return Encoding.UTF8.GetString(Convert.FromBase64String(_data));
}
else
{
return _data;
}
}
set { }
}

public string _rawData { get; set; }
public string fieldType { get; set; }
public int isFree { get; set; }
public string position { get; set; }
}

Please Log in or Create an account to join the conversation.

More
7 years 8 months ago #6032 by admin
Replied by admin on topic SobiPro GeoFields don't look right
Hi Ian,
sorry for delay (these days I am really busy), but I am glad to see you were able to manage the issue by yourself. Just let me know if there is still something opened.

Kind regards,
Luigi
The following user(s) said Thank You: IanF

Please Log in or Create an account to join the conversation.

More
7 years 8 months ago - 7 years 8 months ago #6036 by IanF
Replied by IanF on topic SobiPro GeoFields don't look right
Hi Luigi,

I have my interface up and working. This is a great little component.

Although i have managed to pull the lat and long from the Geo data I still don't recognise the format. My tech friends are saying it's json but I've never seen json in this format. Is it json or a format that you have created?

. I'm thinking of adding community builder to my website. Is there a beta version I can play with?
Last edit: 7 years 8 months ago by IanF.

Please Log in or Create an account to join the conversation.

More
7 years 8 months ago - 7 years 8 months ago #6038 by admin
Replied by admin on topic SobiPro GeoFields don't look right
Hi Ian.

About the pending question, they are just the "serialized" version af a PHP array. You can test it with this little snippet of PHP code:
<?php
	// YToyOntzOjg6ImxhdGl0dWRlIjtkOjU0Ljg3OTA1OTg7czo5OiJsb25naXR1ZGUiO2Q6LTEuNTc1MjMyMzAwMDAwMDM4ODt9

	$a = 'a:2:{s:8:"latitude";d:54.8790598;s:9:"longitude";d:-1.5752323000000388;}';
	$b = unserialize($a);
	var_dump($b);

array(2) { ["latitude"]=> float(54.8790598) ["longitude"]=> float(-1.5752323) }

Sorry but I don't understand the CB question, CB is not mine...

Kind regards,
Luigi
Last edit: 7 years 8 months ago by admin.

Please Log in or Create an account to join the conversation.

Time to create page: 0.156 seconds