Advice about heating plant (pipes, polylines...)

I want to map heating plant with cesium. It implies a lot of pipes and polygons/buildings. Pipes are most complex.
I don't have problem with polygons but with pipes. Pipes for example is polyline 3d geojson.

Trouble is with pipes and diameter from attributes, how to accomplish that?

I will use using Mapguide server 3.1, and with REST can get geojson or czml.

What is the best way to accomplish task, maybe other format?

Cesium, last 1.42
Windows, IIS or Node??
Chrome, Firefox

P.S. I know I have explained briefly, I'm just a beginner.

//polyline

var geojsonOptions = {
        clampToGround: false
    };
    // Load from a GeoJson file

    var podaci = Cesium.GeoJsonDataSource.load('./Source/SampleData/rsw.geojson', geojsonOptions);
    // Save an new entity collection of neighborhood data
    var test;
    podaci.then(function (dataSource) {
        // Add the new data as entities to the viewer
        viewer.dataSources.add(dataSource);
        test = dataSource.entities;

        // Get the array of entities
        var neighborhoodEntities = dataSource.entities.values;
        for (var i = 0; i < neighborhoodEntities.length; i++) {
            var entity = neighborhoodEntities[i];

            if (Cesium.defined(entity.polyline)) {
                entity.polyline.material = Cesium.Color.HOTPINK
// HERE I NEED TO DEFINE PIPE DIAMETER FROM ATTRIBUTE???
            }
            
        }
       
    });

If you are using polylines, you can set the width property:

if (Cesium.defined(entity.polyline)) {

entity.polyline.material = Cesium.Color.HOTPINK;

entity.polyline.width = 1px; // Width of the line in pixels

}

``

But from the sounds of what you are trying to do with pipes, I would suggest using polyline volumes (see PolylineVolume documentation) instead of polylines, as they will let you set the diameter in distance rather than pixels as well as other properties like the shape.

Thanks Gabby,

My problem now is to to realize how to work with elevations, terrain, ellipsoid to determine proper spatial format. Elevations from geometry or attribute and so one.

I want to show coordinates (longitude, latitude and height, I spouse it's ellipsoid height...)on mouse move. I have trouble with promise when I get longitude and latitude. Can you see code below.
Thanks you in advance for your time.

'// Construct the default list of terrain sources.
var terrainModels = Cesium.createDefaultTerrainProviderViewModels();

// Construct the viewer, with a high-res terrain source pre-selected.
var viewer = new Cesium.Viewer('cesiumContainer', {
    terrainProviderViewModels: terrainModels,
    selectedTerrainProviderViewModel: terrainModels[1] // Select STK High-res terrain
});
//_______________________________________________________

//show mousemove coordinates
var entity = viewer.entities.add({
    id: 'mousemoveLabel',
    label: {
        show: true
    }
});

var mouseLabelCb = function (e) {
    var ellipsoid = viewer.scene.globe.ellipsoid;

    // Mouse over the globe to see the cartographic position

    var cartesian = viewer.camera.pickEllipsoid(new Cesium.Cartesian3(e.clientX, e.clientY, e.clientZ), ellipsoid);
    if (cartesian) {

        var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
        var longitudeString = Cesium.Math.toDegrees(cartographic.longitude).toFixed(2);
        var latitudeString = Cesium.Math.toDegrees(cartographic.latitude).toFixed(2);
        var heightString; //i know height is zero
        var postitions =[longitudeString, latitudeString]

        // here I need https://cesiumjs.org/Cesium/Build/Documentation/sampleTerrain.html
        // Now I have longitudeString and latitudeString for promise
        // Maybe something like this, please help here

        var promise = Cesium.sampleTerrain(terrainProvider, 11, positions); //what 11 means?
        Cesium.when(promise, function(updatedPositions) {
        // positions[0].height and positions[1].height have been updated.
        // updatedPositions is just a reference to positions.
});

        entity.position = cartesian;
        entity.label.show = true;
        entity.label.text = '(' + longitudeString + ', ' + latitudeString +','+heightString+')';

    } else {
        entity.label.show = true;
    }
};

viewer.scene.canvas.addEventListener('mousemove', mouseLabelCb);
viewer.scene.canvas.addEventListener('wheel', mouseLabelCb);'

I think what you’ll want is in the Picking Sandcastle example.

Click “Pick Position”, and the example code starts at line #127:

name : ‘milktruck’,

position : Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706),

model : {

uri : ‘…/…/…/…/Apps/SampleData/models/CesiumMilkTruck/CesiumMilkTruck-kmc.gltf’

}

});

viewer.zoomTo(modelEntity);

var labelEntity = viewer.entities.add({

label : {

show : false,

showBackground : true,

font : ‘14px monospace’,

horizontalOrigin : Cesium.HorizontalOrigin.LEFT,

verticalOrigin : Cesium.VerticalOrigin.TOP,

pixelOffset : new Cesium.Cartesian2(15, 0)

}

});

// Mouse over the globe to see the cartographic position

handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);

handler.setInputAction(function(movement) {

var foundPosition = false;

var scene = viewer.scene;

if (scene.mode !== Cesium.SceneMode.MORPHING) {

var pickedObject = scene.pick(movement.endPosition);

if (scene.pickPositionSupported && Cesium.defined(pickedObject) && pickedObject.id === modelEntity) {

var cartesian = viewer.scene.pickPosition(movement.endPosition);

if (Cesium.defined(cartesian)) {

var cartographic = Cesium.Cartographic.fromCartesian(cartesian);

var longitudeString = Cesium.Math.toDegrees(cartographic.longitude).toFixed(2);

var latitudeString = Cesium.Math.toDegrees(cartographic.latitude).toFixed(2);

var heightString = cartographic.height.toFixed(2);

labelEntity.position = cartesian;

labelEntity.label.show = true;

labelEntity.label.text =

‘Lon: ’ + (’ ’ + longitudeString).slice(-7) + ‘\u00B0’ +

‘\nLat: ’ + (’ ’ + latitudeString).slice(-7) + ‘\u00B0’ +

‘\nAlt: ’ + (’ ’ + heightString).slice(-7) + ‘m’;

labelEntity.label.eyeOffset = new Cesium.Cartesian3(0.0, 0.0, -cartographic.height * (scene.mode === Cesium.SceneMode.SCENE2D ? 1.5 : 1.0));

foundPosition = true;

}

}

}

if (!foundPosition) {

labelEntity.label.show = false;

}

}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);

``

Thanks Gabby

Ok, I already did'it with next code (works only in 3d):

function mouseCoordinates() {

    //label
    var entity = viewer.entities.add({
        id: 'mousemoveLabel',
        label: {
            //show: true,
            showBackground: true,
            horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
            verticalOrigin: Cesium.VerticalOrigin.BOTTOM
        }
    });

    var handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas, false);
    handler.setInputAction(
        function (movement) {
            var ray = viewer.camera.getPickRay(movement.endPosition);
            var position = viewer.scene.globe.pick(ray, viewer.scene);
            if (Cesium.defined(position)) {
                var positionCartographic = Cesium.Ellipsoid.WGS84.cartesianToCartographic(position);
                var cartographic = Cesium.Cartographic.fromCartesian(position);
                var heightString = positionCartographic.height.toFixed(2);
                var longitudeString = Cesium.Math.toDegrees(cartographic.longitude).toFixed(2);
                var latitudeString = Cesium.Math.toDegrees(cartographic.latitude).toFixed(2);
                entity.position = position;
                entity.label.show = true;
                entity.label.text = '(' + longitudeString + ', ' + latitudeString + ',' + heightString + ')';
            }
            else {
                entity.label.show = true;
            }

        },
        Cesium.ScreenSpaceEventType.MOUSE_MOVE
    );

Now I realize something about heights. Terrain have ellipsoid heights, and I have above see level (orthometric heights) and my features are slightly under surface. So I must transform or change geodetic datum. Any hint?

P.S. How to put code highlighted?

Hi, I’m not sure what the issue your having is, could you clarify?

(ctrl+shift+e to highlight code in the forum post editor)