Country Borders and Lat/Long Lines

I was wondering if some knew how to integrate these things.

I’ve downloaded a zip file from http://www.naturalearthdata.com/downloads/10m-cultural-vectors/ but I have no idea what I am supposed to do next and how I integrate it into my code. I think through some research I can convert a shape file using ShapefileToCesiumLanguage, but I am not sure if that’s the most up-to-date way to do this. How do use this code? Do I run it in an IDE or an editor? I have downloaded Notepad++, but I am not sure how to use it or what to do next

.

Similarly, I have found code that someone has already written that creates lat long lines here https://github.com/leforthomas/cesium-addons/blob/master/Graticule.js but again I have no idea how to make this work in my code. I tried to just first copy and paste it into Sandcastle and nothing happened. So I added the line Graticule(); at the end since that’s the name of the function and got lots of errors.

Does anyone know what I am doing wrong? Or can shed some guidance on how to fix either of these two problems.

Thanks

Emily

See my earlier post at https://groups.google.com/d/msg/cesium-dev/hjG83E7Pb7M/SVnmZcvvrosJ for an outline of what you’ll need to do. The short version is that you’ll need to convert the data from “shapefile” format into the appropriate CZML format offline on your computer, then write code to load it into Cesium using the CzmlDataSource class.

Now, the good news is that I finally got permission to actually contribute my shapefile-related CZML-Writer changes back. I made them almost two years ago, so they’re probably pretty out-of-date compared to the current build of CZML-Writer. I’ve just forked the CZML-Writer repo to https://github.com/markerikson/czml-writer , and will see if I can re-implement those changes sometime today.

Having said that, I am also attaching the country border and label files I generated myself. You can load them into Cesium using something along these lines:

var dataSourceCollection = new Cesium.DataSourceCollection();
var dataSourceDisplay = new Cesium.DataSourceDisplay({
scene : scene,
dataSourceCollection : dataSourceCollection
});

var czmlFiles = [“countryborders.czml”, “countrylabels.czml”];

czmlFiles.forEach(function(filename) {
var czmlDataSource = new Cesium.CzmlDataSource();
czmlDataSource.loadUrl(filename).then(function() {
dataSourceCollection.add(czmlDataSource);
dataSourceDisplay.update(new Cesium.JulianDate());
});
});

``

There’s probably a better way to do that, but that’s roughly the working code that’s in my application now.

Also, if I could give one general piece of advice: while I do applaud your willingness to ask questions, it looks like you’re doing a lot of copying and pasting code trying to make a couple things work, but without really understanding what’s really going on with the code. I would suggest that you take some time to do some reading and learning on both Javascript and Cesium. Go through some JS tutorials, read through the Cesium examples, look up the details of each line of code and try to understand exactly what each line does. One of the great things about trying to learn programming today is that all the info and tools you could ever possibly need are available for free online. One JS book I’ve seen recommended is http://eloquentjavascript.net/ , but there’s all kinds of other resources as well.

Please don’t take this as a brush-off or an attempt to make you stop asking questions, but rather as an encouragement to better learn the tools and concepts involved in using Cesium. It’s always easier to solve a problem when you have a good foundation to work with :slight_smile:

Mark Erikson

CZMLCountryBordersAndLabels.zip (209 KB)