[Manifold-l] RE: Manifold-l Digest, Vol 22, Issue 1
adamw at manifold.net
adamw at manifold.net
Thu Aug 9 08:17:09 CDT 2007
> > > ...and, if not, try the following query:
> > >
> > > SELECT ID, First(P) G FROM (
> > > SELECT ID, P FROM [Drawing]
> > > SPLIT BY Coords([Geom (I)]) P
> > > ORDER BY CentroidX(P), CentroidY(P)
> > > ) GROUP BY ID
> > >
> > > Just link it as a drawing.
> >
> > Having, I'm afraid zero experience with queries, I'm having a little
> > trouble here; when I try to run this I get a 'token expected" error.
>
> Don't feel bad - I've been using manifold for years and find the folks
> who post these obscure SQL statements marginally useful. They show off
> the posters arcane knowledge of SQL and Manifold internals but that is
> about it. Such solutions are OK for one time throw away solutions but
> if you can't understand them you won't learn anything from them.
Well, if the problem could be easily solved with the help of an interactive tool, I would have suggested that. But, I agree with your point that posting a query without an explanation of what it does is of limited usefulness. Let's correct that.
Let's start by selecting the object IDs and their geometries:
SELECT ID, [Geom (I)] FROM [Drawing]
Let's now split geometries into coordinates so that an object with 5 coordinates ends up with 5 records, with each record having the ID of the object and one of the coordinates:
SELECT ID, P FROM [Drawing]
SPLIT BY Coords([Geom (I)]) P
Let's now reorder the records so that coordinates for each object are sorted lexicographically, that is, first by X and then by Y:
SELECT ID, P FROM [Drawing]
SPLIT BY Coords([Geom (I)]) P
ORDER BY CentroidX(P), CentroidY(P)
Finally, let's leave only the first record for each object:
SELECT ID, First(P) G FROM (
SELECT ID, P FROM [Drawing]
SPLIT BY Coords([Geom (I)]) P
ORDER BY CentroidX(P), CentroidY(P)
) GROUP BY ID
> It the case of the query below I can't get it to return anything
> useful even without the token error.
Are you running the latest version of 7x (7.1.19.2132)?
> If this is in reference to a real problem for you I'd suggest you post
> on the user community and include a .map file (the files are added
> just before the final post) with sample data. Also include how
> accurate the output needs to be. And I'd also suggest some big picture
> prose - you may be asking the wrong question.
I second that.
--
Adam Wachowski
Manifold Development Team
More information about the Manifold-l
mailing list