Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
I have no pleasure continuing my macros are evil tales but the life of C++ programmer eagerly wants to writes add another chapter to the story. Today, it’s time to rant on Apple and its XCode.
One of Boost Geometry (aka GGL) users, Mark, reported that he can not compile his program using the library with GNU C++ compiler from XCode. The compiler throws mysterious complain of a very low-level nature of C++ programming language:
Expected unqualified-id before 'do' in /usr/local/include/boost_1_42_0/boost/geometry/geometries/concepts/check.hpp
Thanks to follow-up by Stjepan we quickly know who to blame for that. It is XCode header AssertMacros.h. It even might be one of public headers from development package of XNU, the Mac OS X kernel, what’s even more fun.
Boost Geometry defines function template for concept checking:
template <typename Geometry>
inline void check()
{
detail::checker<Geometry, boost::is_const<Geometry>::type::value> c;
boost::ignore_unused_variable_warning(c);
}
Apple XCode defines macro using exactly the same name as the function check. The C++ preprocessor, which operates before compiler, substitutes the name check with content of the macro. For the Boost Geometry function check it means that a pile of garbage is injected in place were the function name is expected:
template <typename Geometry>
inline void do { if ( __builtin_expect(!(), 0) ) { DebugAssert('?*?*',
0, "Third Party Client" ": " "", 0, 0, "/usr/local/include/boost/
geometry/geometries/concepts/check.hpp", 181, (void*)0); } } while ( 0 )
{
detail::checker::type::value> c;
boost::ignore_unused_variable_warning(c);
}
Obviously, it makes compiler to give up to instantiate the check function from the template and to compile it properly.
C/C++ macros are evil, however, not by design but by insanity of programmers. Every macro defined in a public C/C++ header, should be defined using as unique as possible, but still usable name. I wish Apple folks designed their C/C++ macros as unique as they make their hardware products, even if made in China eventually. This particular macro that caused the problems discussed here, could be named to APPLE_XNU_CHECK and life would be easier. Or, given the fact that almost 3000 files using these identifiers live in Boost C++ Libraries only, I probably should say: life would be more productive, efficient and cheaper.
By the way, it’s a known problem @ Boost and it looks Boost Folks are trying to figure out best solution. See ticket #2115 – Avoid bad Apple macros.
…to be continued
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.

This looks interesting: http://infochimps.org/search?query=soil
I have just given ohloh.net kudos to Richard Stallman and Linus Torvalds.
Hehe, and I didn’t do it because I expect to be given back with a kudo from RMS or Torvalds. I did it because I appreciated the bloody good software development works they do: my favourite C/C++ compiler from GCC, one of my favourite text editors GNU Emacs and my favourite operating system – Unix for Masses and my favourite version control system Git.
As a long time user of Subversion, I’ve got used to use of svn info command. Since I started drifting to Git system, I’ve missed this command pretty much until I found git-info script crafted by Duane Johnson
Kudos to Duane! And, I suggest any SVN user who reincarnated as Git user to grab and try it.
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
These events allow us the opportunity to engage in conversations and dialogs with various technologists because we want to gain feedback about the needs of open source developers and users. The objective of course is to channel this information back to development so we can reflect this in future products and business decisions in order to best support our customers.So far ESRI attendance has been at the managerial level, and while I love those guys (hugs to Satish and Victoria!) some real sparks could fly and serious interoperability improvements be made if we started seeing the developers, the project leads and software designers, at the events. We can do better than "channeling" information back to development, let's immerse development in it!
GCS Model Grids
Recently finished some collaborative work with Vishal, related to visualizing climate change data for the SEI. This project was funded in part by the California Energy Commission, with additional technical support from the Google Earth Team. One of the final products was an interactive, multi-scale Google Earth application, based on PostGIS, PHP, and R. Interaction with the KMZ application results in several presentations of climate projections, fire risk projections, urban population growth projections, and other related information. Charts are dynamically generated from the PostGIS database, and returned to the web browser. In addition, an HTTP-based interface makes it simple to download CSV-formatted data directly from the CEC server. Some of our R code seemed like a good candidate for sharing, so I have posted a complete example below-- illustrating how to access climate projection data from the CEC server, a couple custom functions for fancy lattice graphics, and more.
another plyr example quantiles (0.05, 0.25, 0.5, 0.75, 0.95) of DSC by temperature bin
There are plenty of good examples on how to use functions from the plyr package. Here is one more, demonstrating how to use ddply with a custom function. Note that there are two places where the example function may blow up if you pass in poorly formatted or strange data: calls to 1) t.test() and 2) quantile(). Also note the use of the transpose function, t(), for converting column-wise data into row-wise data-- suitable for inclusion into a dataframe containing a single row.
Read more of this story at Slashgeo.
Recently, I was playing for a while with Brian’s new OGR LIBKML driver and I integrated it with GDAL/OGR build system, so it’s more convenient to build, test and use it. The complete tree is available in GDAL sandbox in mloskot/winkey-libkml. (It is just a give it a try-like prototype and I don’t actively maintain this branch myself. Hopefully, Brian will take it over.)
By the way, I crafted AX_LIB_LIBKML macro for Autoconf. This macros checks for headers and libraries of specified version (or newer) of Google libkml library and defines compilation and linking flags.
I submitted the macro to GNU Autoconf Archive. It is the new incarnation of well-known autoconf-archive.cryp.to. Peter Simons announced not long time ago that
The archive has moved to Savannah: http://www.nongnu.org/autoconf-archive/. Version 2009-04-26 was the last to be released at autoconf-archive.cryp.to.
Happy detecting libkml!
Const-correctness rants are quite common topic of chats on #gdal IRC channel. Some of the pearls I’ve got printed in to my mind:
A: The lesson is I ought to get things right the first time.
B: The issue withconstmethod is that if you want to add lazy loading later, it can cause problems
C: GDAL is rather painful to use withconstcorrect code, unfortunately :(
B: The solution is obvious: don’t writeconstcorrect code
Who’s right then, A or B?
I recall another motto from #gdal channel that sounds like “when unsure, do nothing” which has the following rationale:
especially when I realize afterwards that I’ve f**cked things because I neglected to follow the motto
Remembering these recommendations, it’s pretty clear why the const-mess in GDAL has happened. I’d conclude paraphrasing the motto this way:
I’ve f**cked things because I neglected to make a decision.
Now, poor GDAL beginner deadpickle, trying to find out (it’s me the evil) why compiler complains about his not-that-bad-written code, wandered to find and ask C gurus @ comp.lang.c and got the problem explained by Malcolm who wrote:
The problem is that, when C was first developed, there was no const keyword. So strings literal, which are constant, had to be non-const for backwards compatibility. This means that lots of programmers get lazy and omit the const, even from functions which don’t modify their string arguments. (There are also some subtle problems with const which means that this isn’t always a case of pure laziness). So a sort of solution is to discard the const qualifiers. However this is perpetuating the problem in your own code.
The motto stays in contradiction to a well-known best practice of const correct sooner than later. It’s way easier and cheaper to remove const-correctness once it turns out it does not express properly the actual design and contract than to apply it to existing codebase. Sometimes, the latter is even not possible making things f**cked up twice, in existing code base and in client’s code.
Bill Hoffman just notified on the CMake mailing list:
At 4:30, I am going to be interviewed for FLOSS Weekly.
The chat is here:
http://irc.twit.tv/
The video is here:
http://live.twit.tv/
Should be going on some time around 4:30 EST.
It’s on now.
UPDATE: FLOSS Weekly 111: CMake archived audio podcast
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
The most obvious difference is that the type numbers for encoding the presence of Z- and M-dimensions are not the ones described in the old OGC extension document [OGC members only, cited by Martin Daly in 2004, and extended further for PostGIS by Sandro Santilli that year] for WKB. Instead of setting high-bits to indicate the presence of Z and M, as OGC did, the ISO spec simply adds 1000. i) Case:Representing an empty point in WKB is hard because there's nowhere obvious to indicate the lack of ordinates. But the ISO specification makes no attempt to solve the problem, they instead provide explicit guidance that is impossible to implement. Basically, if you are reading a WKB POINT and there are doubles after the TYPE number, you have a POINT(x y). If not, you have a POINT EMPTY. All well and good, but how do you distinguish, in a collection of WKB geometries, between the presence of doubles in the byte stream and the presence of another geometry in the stream? You don't.
i) If <point binary representation> immediately contains a <wkbpoint binary>, then <point binary representation> is the well-known binary representation for an ST_Point value that is produced by <wkbpoint binary>.
ii) Otherwise, <point binary representation> produces an empty set of type ST_Point
q) Case:As with the POINT case, the WKB reader is supposed to magically distinguish between an element of the current geometry (the <num>) in the byte-stream and an element of the next geometry in the byte-stream. And worse, the "clarifying" comment implicitly adds a whole new kind of empty geometry! What if the <num> is present, but the value is zero!?!
i) If <linestring binary representation> immediately contains <num>, then <linestring binary representation> is the well-known binary representation for an ST_LineString value. Let APA be an ST_Point ARRAY value with cardinality of <num> that contains the ST_Point values specified by the immediately contained <wkbpoint binary>s. <linestring binary representation> produces an ST_LineString value as the result of the value expression: NEW ST_LineString(APA).
ii) Otherwise, <linestring binary representation> produces an empty set of type ST_LineString.
Sidenote: As a result of WKB not having SRID support, it's not possible to round-trip a geometry through WKB without losing the SRID value. Try this standard SQL and see what happens:As it stands now, the specification is out of synch with the implementations on the ground, which is bad news for the relevance of the specification. I will be implementing EMPTY using the same semantics as SQLServer, which will make the kinds of EMPTY PostGIS can represent slightly richer, but remain backwards compatible to the old schemes.SELECT ST_SRID( ST_GeomFromWKB( ST_AsBinary( ST_GeomFromText('POINT(0 0)', 4326 ) ) ) )
Then try the bastardized PostGIS EWKB format instead:SELECT ST_SRID( ST_GeomFromEWKB( ST_AsEWKB( ST_GeomFromText( 'POINT(0 0)', 4326 ) ) ) )
Read more of this story at Slashgeo.


Here we go! 23 programmers are winging their way to the Big Apple to take part in the New York code sprint, combining coding talent talent from MapServer, PostGIS, GDAL, OpenLayers, Geoserver, LibLAS, and, and, and!Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
(ED: Enabling comments might help.. sorry about that, should work now. TM)
I talk a fair bit with various folks about book ideas they or I have. I'm curious on your thoughts for potential new books that might be popular - what's the next big "geo" book that you think you, your colleagues, the world at large needs?
Where do these books leave off? Or what new waters need to be charted?
Maxim Dubinin syndicated GIS-Lab blog with the Planet OSGeo aggregator.
A few words about GIS-Lab from their website:
GIS-Lab – informal non-commercial community of GIS/RS specialists, we grow ourselves and help grow others.
GIS-Lab exists since April 2002 as an independent online resource specializing in geographic information systems (GIS) and remote sensing (RS). At present, the site is primarily oriented towards Russian-speaking GIS community, however, we do our best to translate as many materials as possible into English.
The GIS-Lab is the very first blog in Russian language syndicated with the Planet OSGeo, what makes the planet yet more international geo-caffee.
Inspired by question Paul Ramsey asked today morning on IRC, I’ve inspected what kind of Well-Known-Binary output gives SqlGeometry for EMPTY geometries of all the seven geometry types as specified in OGC SFS. The SqlGeometry class is available from SQL Server System CLR Types for .NET Framework. Here we go.
I checked Well-Known-Binary output as returned by the SqlGeometry method STAsBinary(). Here is a small test program written in C#:
using System;
using System.Linq;
using Microsoft.SqlServer.Types;
namespace SqlGeometryEmpty
{
class Test
{
static void Main(string[] args)
{
foreach (string type in
Enum.GetNames(typeof(OpenGisGeometryType)))
{
string wkt = type.ToUpper() + " EMPTY";
SqlGeometry geom = SqlGeometry.Parse(wkt);
byte[] wkb = geom.STAsBinary().Buffer;
string wkbhex = string.Join("",
wkb.Select(
b => b.ToString("X2")).ToArray());
Console.WriteLine("{0}\n{1} ({2} bytes)\n",
wkt, wkbhex, wkb.Length);
}
}
}
}
The first observation is that WKB of EMPTY geometry for all types is returned as a a slightly different binary. All the binary forms are truncated to nine bytes. The first byte indicates endianness as expected. The second chunk of four bytes indicate geometry type. It is exactly as defined in OGC specifications. The third chunk of remaining four bytes are set to Zero and seem to play a role of size specifier: number of points in LINESTRING or number of rings in POLYGON, number of points in MULTIPOINT, and so on. This makes another observation that WKB for EMPTY is reported as a collection of primitive components.
The difference in binary of WKB of EMPTY geometry I mentioned is in that the actual type of input geometry is preserved, so there seems to be no implicit translation to geometry of some other type.
So far so good but not for too long. In fact, SqlGeometry implicitly casts POINT EMPTY to MULTIPOINT EMPTY geometry with the WKB of the following form (in hex):
010400000000000000
Here is complete output of the test program above:
POINT EMPTY 010400000000000000 (9 bytes) LINESTRING EMPTY 010200000000000000 (9 bytes) POLYGON EMPTY 010300000000000000 (9 bytes) MULTIPOINT EMPTY 010400000000000000 (9 bytes) MULTILINESTRING EMPTY 010500000000000000 (9 bytes) MULTIPOLYGON EMPTY 010600000000000000 (9 bytes) GEOMETRYCOLLECTION EMPTY 010700000000000000 (9 bytes)
A word about how PostGIS behaves. PostGIS reports GEOMETRYCOLLECTION EMPTY, regardless of actual type of input EMPTY geometry. It is in hex form:
010700000000000000
Generally, there is not many choices of how to report EMPTY geometry in clear and usable way and a form of collection with size equal to Zero seems to be the most appropriate choice. POINT EMPTY reported with type set to POINT (010100000000000000) would be ambiguous as feels like truncated or invalid form of POINT(0 0), especially in programming languages like C where native dynamic allocated arrays do not carry information about their size. IOW, geometry type is not enough information to process binary form of POINT EMPTY properly.
Reporting EMPTY geometries as a collection is a useful convention that seems to work well. PostGIS behaves about it in the very consistent manner reporting one type for all empties. SqlGeometry, so SQL Server, forces programmers to write a few more lines of code to handle all the possible cases. Yet another original exotic solution from Microsoft.
Consistent API is a bless!
Update: consistent specification of interface is even better.
Read more of this story at Slashgeo.
Hope to see you at the MapServer introduction workshop at FOSS4G 2010 in Barcelona this September.
As usual, it's a team teaching approach for beginners, delivered by Jeff McKenna, Perry Nacionales and myself.
This workshop always sells out and people beg to join in or stand at the back - so sign up soon or you might miss out.
See you there!
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
iPhone App Screenshot rev 0.2 - icon
iphone App Screenshot rev 0.2 - in Fresno
More Updates:
The application is now available on the Apple iTunes Store. Preliminary documentaion here.
Stumbled upon an excellent example of how to perform numerical integration in R. Below is an example of piece-wise linear and spline fits to FTIR data, and the resulting computed area under the curve. With a high density of points, it seems like the linear approximation is most efficient and sufficiently accurate. With very large sequences, it may be necessary to adjust the value passed to the subdivisions argument of integrate(). Strangely, larger values seem to solve problems encountered with large datasets...
I’m pleased to announce two new blogs I have just syndicated with the Planet OSGeo aggregator.
It is:
Welcome to the Planet OSGeo!
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
Read more of this story at Slashgeo.

Read more of this story at Slashgeo.
Read more of this story at Slashgeo.
Principal Coordinates (of) Neighbor Matrices (PCNM) is an interesting algorithm, developed by P. Borcard and P. Legendre at the University of Montreal, for the multi-scale analysis of spatial structure. This algorithm is typically applied to a distance matrix, computed from the coordinates where some environmental data were collected. The resulting "PCNM vectors" are commonly used to describe variable degrees of possible spatial structure and its contribution to variability in other measured parameters (soil properties, species distribution, etc.)-- essentially a spectral decomposition spatial connectivity. This algorithm has been recently updated by and released as part of the PCNM package for R. Several other implementations of the algorithm exist, however this seems to be the most up-to-date.
Related Presentations and Papers on PCNM