简体   繁体   中英

Base64 encoding for SAS.Planet

SAS.Planet is a Russian soft, written in Delphi, to download Satellite images from many servers (sasgis.org). It is great and I use it a lot, but it would be better if I could insert my own data to it. It stores data in a file named marks.sml, which is basically a xml file. An example of it goes:

<?xml version="1.0" standalone="yes"?> 
<DATAPACKET Version="2.0"><METADATA><FIELDS>
<FIELD attrname="id" fieldtype="i4" readonly="true" SUBTYPE="Autoinc"/>
<FIELD attrname="name" fieldtype="string" WIDTH="255"/>
<FIELD attrname="descr" fieldtype="bin.hex" SUBTYPE="Text"/>
<FIELD attrname="scale1" fieldtype="i4"/><FIELD attrname="scale2" fieldtype="i4"/>
<FIELD attrname="lonlatarr" fieldtype="bin.hex" SUBTYPE="Binary"/>
<FIELD attrname="lonL" fieldtype="r8"/>
<FIELD attrname="latT" fieldtype="r8"/>
<FIELD attrname="LonR" fieldtype="r8"/>
<FIELD attrname="LatB" fieldtype="r8"/>
<FIELD attrname="color1" fieldtype="i4"/>
<FIELD attrname="color2" fieldtype="i4"/>
<FIELD attrname="visible" fieldtype="boolean"/>
<FIELD attrname="picname" fieldtype="string" WIDTH="255"/>
<FIELD attrname="categoryid" fieldtype="i4"/></FIELDS>
<PARAMS AUTOINCVALUE="3"/></METADATA><ROWDATA>
<ROW id="1" name="Prueba1" descr="06/04/2015 9:48:56" scale1="2" scale2="0" lonlatarr="ANBXOtFZZY8FwABITxpq702zBMAgSCcJANBXOlGCU48FwABA1S48rk+zBMAgSCcJANBXOlEvPY8FwACo0VkXqlWzBMAgSCcJANBXOtGRPI8FwADYDRHFYGKzBMAgSCcJ" lonL="-71.69795087659068" latT="-44.826108606201" LonR="-71.61829999768443" LatB="-44.84607227245893" color1="-1493237760" color2="0" visible="TRUE" picname="" categoryid="1"/>
<ROW id="2" name="Prueba Polygon" descr="06/04/2015 10:16:25" scale1="2" scale2="0" lonlatarr="ANBXOtEeN48FwABAFiGe6lSzBMD89hIAANBXOlGPN48FwAAoQlXdQGKzBMD89hIAANBXOtELLI8FwACAC5X1IGKzBMD89hIAANBXOlEUK48FwACA1erKqlSzBMD89hIAANBXOtEeN48FwABAFiGe6lSzBMD89hIAANBXOtEeN48FwABAFiGe6lSzBMD89hIA" lonL="-71.6085152991981" latT="-44.83268277223885" LonR="-71.58413938367076" LatB="-44.84595056374432" color1="-1509949440" color2="872415231" visible="TRUE" picname="" categoryid="1"/>
</ROWDATA></DATAPACKET>

As you can see there is a tag named "ROW" in which are the "shapes". I tried to rewrite it for my own data, but the actual array of points is codified. Searching in the web I found that it is a Base64 encoding (Delphi). And I don't have a clue about it. I read a little about it, but is quit complex. My specific questions are: - Could I make the Base64 encoding in any language? or have to use Delphi only? - If so, does anyone have the code in python?

Thank you!

Decoding base64 data is quite simple.

In [1]: import base64

In [2]: lonlatarr = base64.b64decode("ANBXOtFZZY8FwABITxpq702zBMAgSCcJANBXOlGCU48FwABA1S48rk+zBMAgSCcJANBXOlEvPY8FwACo0VkXqlWzBMAgSCcJANBXOtGRPI8FwADYDRHFYGKzBMAgSCcJ")

In [3]: len(lonlatarr)
Out[3]: 96

In [4]: lonlatarr[0:9]
Out[4]: b'\x00\xd0W:\xd1Ye\x8f\x05'

Interpreting what is means is more difficult.

Notice the regularity in the data:

In [18]: lonlatarr[0:4], lonlatarr[24:28], lonlatarr[48:52]
Out[18]: (b'\x00\xd0W:', b'\x00\xd0W:', b'\x00\xd0W:')

In [19]: len(lonlatarr)
Out[19]: 96

In [20]: lonlatarr[41:48], lonlatarr[89:96]
Out[20]: (b"\xb3\x04\xc0 H'\t", b"\xb3\x04\xc0 H'\t")

In [21]: lonlatarr[17:24], lonlatarr[41:48], lonlatarr[89:96]
Out[21]: (b"\xb3\x04\xc0 H'\t", b"\xb3\x04\xc0 H'\t", b"\xb3\x04\xc0 H'\t")

A sequence begins with b'\\x00\\xd0W:' and ends with b"\\xb3\\x04\\xc0 H'\\t". The data inbetween varies. It could be that these mark the beginning and end of a longitude or latitude. Or it could be that the beginning and end of the numbers are always the same because of their range and encoding.

Fortunately, the code for this program seems to be available .

Your file might have something to do with the MarksDB ? It's hard to tell.

It might be a good idea to contact the developers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM