Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- Improved performance when removing primitives. [#3018](https://github.com/CesiumGS/cesium/pull/3018)
- Improved performance of terrain Quadtree handling of custom data [#12907](https://github.com/CesiumGS/cesium/pull/12907)
- Fixed picking of `GroundPrimitive` with multiple `PolygonGeometry` instances selecting the wrong instance. [#12978](https://github.com/CesiumGS/cesium/pull/12978)
- Fixed WMS GetFeatureInfo requests to correctly projects the results based on schema projection. [#12993](https://github.com/CesiumGS/cesium/pull/12993)

## 1.134.1 - 2025-10-10

Expand Down
34 changes: 34 additions & 0 deletions Specs/Data/WMS/GetFeatureInfo-GeoJSON-mercator.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"id": "bores.641",
"geometry": {
"type": "Point",
"coordinates": [1406877.9886, 5326443.0126]
},
"geometry_name": "the_geom",
"properties": {
"OBJECTID": 2956,
"FEATTYPE": "Bore",
"NAME": "TOP TANK",
"FEATREL": "1980-12-31T13:00:00Z",
"ATTRREL": "1980-12-31T13:00:00Z",
"PLANACC": 100,
"SOURCE": "GEOSCIENCE AUSTRALIA",
"CREATED": "2006-05-08T14:00:00Z",
"RETIRED": null,
"PID": 527738,
"SYMBOL": 11,
"FEATWIDTH": 0,
"ORIENTATN": 0,
"TEXTNOTE": ""
}
}],
"crs": {
"type": "EPSG",
"properties": {
"code": "3857"
}
}
}
18 changes: 13 additions & 5 deletions packages/engine/Source/Scene/GetFeatureInfoFormat.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Cartesian3 from "../Core/Cartesian3.js";
import Cartographic from "../Core/Cartographic.js";
import defined from "../Core/defined.js";
import DeveloperError from "../Core/DeveloperError.js";
import GeographicProjection from "../Core/GeographicProjection.js";
import RuntimeError from "../Core/RuntimeError.js";
import ImageryLayerFeatureInfo from "./ImageryLayerFeatureInfo.js";

Expand Down Expand Up @@ -70,8 +72,7 @@ function GetFeatureInfoFormat(type, format, callback) {

this.callback = callback;
}

function geoJsonToFeatureInfo(json) {
function geoJsonToFeatureInfo(json, projection) {
const result = [];

const features = json.features;
Expand All @@ -86,9 +87,16 @@ function geoJsonToFeatureInfo(json) {

// If this is a point feature, use the coordinates of the point.
if (defined(feature.geometry) && feature.geometry.type === "Point") {
const longitude = feature.geometry.coordinates[0];
const latitude = feature.geometry.coordinates[1];
featureInfo.position = Cartographic.fromDegrees(longitude, latitude);
const x = feature.geometry.coordinates[0];
const y = feature.geometry.coordinates[1];

if (!defined(projection) || projection instanceof GeographicProjection) {
featureInfo.position = Cartographic.fromDegrees(x, y);
} else {
const positionProjected = new Cartesian3(x, y, 0);
const cartographic = projection.unproject(positionProjected);
featureInfo.position = cartographic;
}
}

result.push(featureInfo);
Expand Down
21 changes: 18 additions & 3 deletions packages/engine/Source/Scene/UrlTemplateImageryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,11 +588,26 @@ UrlTemplateImageryProvider.prototype.pickFeatures = function (
++formatIndex;

if (format.type === "json") {
return resource.fetchJson().then(format.callback).catch(doRequest);
return resource
.fetchJson()
.then((response) =>
format.callback(response, that.tilingScheme.projection),
)
.catch(doRequest);
} else if (format.type === "xml") {
return resource.fetchXML().then(format.callback).catch(doRequest);
return resource
.fetchXML()
.then((response) =>
format.callback(response, that.tilingScheme.projection),
)
.catch(doRequest);
} else if (format.type === "text" || format.type === "html") {
return resource.fetchText().then(format.callback).catch(doRequest);
return resource
.fetchText()
.then((response) =>
format.callback(response, that.tilingScheme.projection),
)
.catch(doRequest);
}
return resource
.fetch({
Expand Down
46 changes: 46 additions & 0 deletions packages/engine/Specs/Scene/WebMapServiceImageryProviderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import {
} from "../../index.js";

import pollToPromise from "../../../../Specs/pollToPromise.js";
import WebMercatorProjection from "../../Source/Core/WebMercatorProjection.js";
import Cartesian3 from "../../Source/Core/Cartesian3.js";

describe("Scene/WebMapServiceImageryProvider", function () {
beforeEach(function () {
Expand Down Expand Up @@ -965,6 +967,50 @@ describe("Scene/WebMapServiceImageryProvider", function () {
});
});

it("works with GeoJSON responses in mercator projection", function () {
const provider = new WebMapServiceImageryProvider({
url: "made/up/wms/server",
layers: "someLayer",
tilingScheme: new WebMercatorTilingScheme(),
});

Resource._Implementations.loadWithXhr = function (
url,
responseType,
method,
data,
headers,
deferred,
overrideMimeType,
) {
expect(url).toContain("GetFeatureInfo");
Resource._DefaultImplementations.loadWithXhr(
"Data/WMS/GetFeatureInfo-GeoJSON-mercator.json",
responseType,
method,
data,
headers,
deferred,
overrideMimeType,
);
};
const projection = new WebMercatorProjection();

return provider
.pickFeatures(0, 0, 0, 0.5, 0.5)
.then(function (pickResult) {
expect(pickResult.length).toBe(1);

const firstResult = pickResult[0];
expect(firstResult).toBeInstanceOf(ImageryLayerFeatureInfo);
expect(firstResult.name).toBe("TOP TANK");
expect(firstResult.description).toContain("GEOSCIENCE AUSTRALIA");
expect(firstResult.position).toEqual(
projection.unproject(new Cartesian3(1406877.9886, 5326443.0126, 0)),
);
});
});

it("works with MapInfo MXP responses", function () {
const provider = new WebMapServiceImageryProvider({
url: "made/up/wms/server",
Expand Down