Can I draw Polygon Holes with a Single string

I am storing a bunch of points into a database, and then querying them out. They have to be stored as one string. The points represent the lat long coordinates of the polygon we want to draw. This works great for one shape. However, it is doing very weird things if you try to make two shapes from one string(picture 1). If you try to make two shapes, and one of them has a hole, it looks like this(picture 2). It also tends to do some weird thing where it connects to (0,0) randomly. The points from this page are being used, and this is the verbatim string that is being parsed for all of these points: “((40 40, 20 45, 45 30, 40 40)), ((20 35, 10 30, 10 10, 30 5, 45 20, 20 35), (30 20, 20 15, 20 25, 30 20))”
This is being parsed correctly to be displayed as one polygon.

The goal is to have one entity be able to represent two shapes, and be able to have holes in those shapes.

If this can be accomplished in another way, I would like to know. I have thought about detecting the commas, then making separate shapes and joining them together (after they’re created) somehow. If this is a possibility, please show me how, or point me in the right direction. I’m fairly new to the API and finding somethings are hard sometimes.



2016-07-13 16_02_17-WMS Cesium Shape File Test.png

2016-07-13 15_59_15-Well-known text - Wikipedia, the free encyclopedia.png

I was about to suggest doing a couple regex steps to split by top-level section and then by subsections, but then I saw you’re talking about Well-Known Text format. Looks like there’s a variety of existing Javascript libraries for parsing and manipulating WKT data, such as and . You should be able to simply parse the WKT into a more suitable format and work with it. In fact, it looks like both of those two libraries can translate WKT into GeoJSON, and Cesium has a GeoJSONDataSource built-in that will turn that data into Cesium Entities.

Thank you! I’ll give that a shot!