Just wanted to revisit this; I have confirmed that this issue still
exists in 1.7.0 and in latest from GitHub. Any thoughts? Is there no
way to get RGB into an LAS file using liblas?
Thanks,
Ryan
On 11/8/2011 4:15 PM, Ryan W. Frenz wrote:
It seems I am unable to read RGB color from points in point format 2.
Using the code snippets below, I write 10 points to a LAS file, with RGB
color, and then read it back. I can read back the coordinates properly
but not the color (I get RGB=0,0,0 for all points). Anything jump out
that I'm doing wrong? Could someone point me to some sample data in
point format 2 that I could use for testing?
Notes:
- This same code works properly using Point Format 0 and
Set/GetIntensity instead of Color.
- I am performing this test using libLAS 1.6.1 compiled for Windows
(same results in 32 and 64 bit).
Thanks in advance,
Ryan
void write(const std::string& filename) {
std::ofstream out(filename, std::ios::binary);
liblas::Header h;
h.SetDataFormatId(liblas::ePointFormat2);
h.SetPointRecordsCount(10);
h.SetPointRecordsByReturnCount(1, 10);
h.SetScale(0.001, 0.001, 0.001);
h.SetOffset(0,0,0);
liblas::Writer w(out, h);
for (double i = 0; i <= 1.0; i+=0.1) {
liblas::Point p;
p.SetX(i); p.SetY(i); p.SetZ(i);
liblas::Color c;
c.SetRed(static_cast<liblas::Color::value_type>(std::numeric_limits<liblas::Color::value_type>::max()
* i));
c.SetGreen(static_cast<liblas::Color::value_type>(std::numeric_limits<liblas::Color::value_type>::max()
* i));
c.SetBlue(static_cast<liblas::Color::value_type>(std::numeric_limits<liblas::Color::value_type>::max()
* i));
p.SetColor(c);
w.WritePoint(p);
}
out.close();
}
void read(const std::string& filename) {
std::ifstream in(filename, std::ios::binary);
liblas::Reader reader(in);
int ct = 0;
while ((ct < 10) && reader.ReadNextPoint()) {
const liblas::Point& p = reader.GetPoint();
std::cerr << p.GetX() << ", " << p.GetY() << ", " << p.GetZ() <<
", " << p.GetColor().GetRed() << ", " << p.GetColor().GetGreen() << ", "
<< p.GetColor().GetBlue() << "\n";
++ct;
}
in.close();
}
--
Ryan W. Frenz
Head of Software Development
Allpoint Systems
1936 Fifth Ave
Pittsburgh, PA 15219
o: 412.444.5149
e: [email protected]
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they are
addressed. If you have received this email in error please notify the
system manager. This message contains confidential information and is
intended only for the individual named. If you are not the named
addressee you should not disseminate, distribute or copy this e-mail.
Please notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system. If you are
not the intended recipient you are notified that disclosing, copying,
distributing or taking any action in reliance on the contents of this
information is strictly prohibited.
_______________________________________________
Liblas-devel mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/liblas-devel