One of our GeoTools users, and a good friend, Werner Macho from Vienna, came up with this request today, "I have a polyline which has lost all its elevation values. Some idiot converted it into a 2d polyline and all the elevations are now reduced to 0.0. Is there a way to get it back using GeoTools?"
Fortunately, he still had the individual point objects with the elevations at the same location where the polyline vertices were.
We devised a solution for him using a couple of GeoTools commands:
1. First, we convert the 2d polyline to a 3d polyline using the GT_CH2D3D command. With this step done, the polyline is now ready to receive the vertex elevations from the points lying on it.
2. However, the elevations cannot be directly transferred from points and have to come from block attributes. So, the next step is to convert these points into blocks. To prepare for this, we create a block with a single attribute to hold the elevation value. The block contains a simple point object and an attribute that will contain the elevation (Z) value.
3. Next, we use the GT_P2BLKSHP command and replace all the points with the newly created block.
4. Next, we use the GT_PROP2ATT command to transfer the elevation value from the block insertion point to the attribute of the block.
5. The last step is to use the GT_ASN_PROP command to 'inherit' the vertex elevations from the attribute of the blocks which are lying on the polyline vertices.
6. You now have a proper 3d polyline in which each vertex has its correct elevation assigned to it. Download a sample DWG to test this procedure...
This is an example of the kinds of problem-solving that can be achieved using a bunch of GeoTools commands in a specific order.