Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error reading array that could be undefined in ows service #8428

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Fix error reading array that could be undefined.
   Cannot read properties of undefined (reading 'length')
ianwallen committed Oct 13, 2024
commit 102ac957964df725da8a719ed09557a17db8c946
Original file line number Diff line number Diff line change
@@ -582,46 +582,48 @@
var needles = [];
var layers = capObj.featureTypeList.featureType;

for (var i = 0, len = layers.length; i < len; i++) {
//check layername
if (
name == layers[i].name.localPart ||
name == layers[i].name.prefix + ":" + layers[i].name.localPart ||
name == layers[i].Name
) {
needles.push(layers[i]);
continue;
}
if (Array.isArray(layers)) {
for (var i = 0, len = layers.length; i < len; i++) {
//check layername
if (
name == layers[i].name.localPart ||
name == layers[i].name.prefix + ":" + layers[i].name.localPart ||
name == layers[i].Name
) {
needles.push(layers[i]);
continue;
}

//check title
if (name == layers[i].title || name == layers[i].Title) {
needles.push(layers[i]);
continue;
}
//check title
if (name == layers[i].title || name == layers[i].Title) {
needles.push(layers[i]);
continue;
}

//check dataset identifer match
if (uuid != null) {
if (angular.isArray(layers[i].Identifier)) {
angular.forEach(layers[i].Identifier, function (id) {
if (id == uuid) {
needles.push(layers[i]);
}
});
//check dataset identifer match
if (uuid != null) {
if (angular.isArray(layers[i].Identifier)) {
angular.forEach(layers[i].Identifier, function (id) {
if (id == uuid) {
needles.push(layers[i]);
}
});
}
}
}

//check uuid from metadata url
if (uuid != null) {
if (angular.isArray(layers[i].MetadataURL)) {
angular.forEach(layers[i].MetadataURL, function (mdu) {
if (
mdu &&
mdu.OnlineResource &&
mdu.OnlineResource.indexOf(uuid) > 0
) {
needles.push(layers[i]);
}
});
//check uuid from metadata url
if (uuid != null) {
if (angular.isArray(layers[i].MetadataURL)) {
angular.forEach(layers[i].MetadataURL, function (mdu) {
if (
mdu &&
mdu.OnlineResource &&
mdu.OnlineResource.indexOf(uuid) > 0
) {
needles.push(layers[i]);
}
});
}
}
}
}