I am reading a shape file and collecting into a QString,but the string is in some binary format, but not getting geometric data(lat,lons).how to read a shape file.
I am reading a shape file and collecting into a QString,but the string is in some binary format, but not getting geometric data(lat,lons).how to read a shape file.
what is a 'shape file'?
How was it generated?
You say it is in binary format, if so, string will not help you much.
You need to know the serialization protocol, and serialized it back.
This has nothing to do with Qt.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
I am using opengl in Qt
here filestr is D:/cochin_vegitation.shp
QFile mfile(filestr);
if(!mfile.open(QFile::ReadOnly |QIODevice::Text))
{
return;
}
QTextStream in(&mfile);
QString mText=in.readAll();
qDebug()<<"textsize"<<mText.size();
for(int i=0;i<mText.size();i++)
{
qDebug()<<"text"<<mText[i];
}
I am getting out put as
text '00\u00a3'
text '?'
text '\x10'
text 'S'
text '@'
text '00\u00af'
text 'H'
text '$'
text '\x1b'
text 'Y'
text '00\u00e7'
text '#'
text '@'
text '\x1'
text '\x0'
text '\x0'
text '\x0'
text '\x5'
text '\x0'
text '\x0'
text '\x0'
text '\x0'
text '\x0'
text '\x0'
text '\x0'
text '('
text 'I'
But i need Geometric data like Latitude,Longitude
nothing in what you added changes the issue.
You need to know how the data is serialized in the shape file.
Without it, there is nothing you can do.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
You need to open the file as a binary file, not text, because it contains binary data, not text data.
The file format of a Shapefile is shown here: https://en.wikipedia.org/wiki/Shapefile. The wikipedia article show the layout of the 100 byte header file that is the first 100 bytes in a shapefile, followed by the various record types that it may contain. You'll have to understand the file layout described the article and then successfully read/parse the records that follow the 100 byte header.
Good luck.
I write the best type of code possible, code that I want to write, not code that someone tells me to write!
Bookmarks