private string GetNameAttributeValue(IDictionary <string, object> attributes, string defaultName) { if (!pointsShapeFileReader.HasAttribute(nameAttributeName)) { return(defaultName); } var attributeNameValue = attributes[nameAttributeName] as string; return(string.IsNullOrWhiteSpace(attributeNameValue) ? defaultName : attributeNameValue); }
public void HasAttribute_VariousCases_ReturnTrueIfMatchesInProperCaseHasBeenFound(string attributeName, bool expectedResult) { // Setup string shapefileFilePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, "Single_Point_with_ID.shp"); using (var reader = new PointShapeFileReader(shapefileFilePath)) { // Call bool result = reader.HasAttribute(attributeName); // Assert Assert.AreEqual(expectedResult, result); } }
public void HasAttribute_AttributeInShapefile_ReturnTrue() { // Setup string shapefileFilePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, "Single_Point_with_ID.shp"); using (var reader = new PointShapeFileReader(shapefileFilePath)) { // Call bool result = reader.HasAttribute("id"); // Assert Assert.IsTrue(result); } }
/// <summary> /// Validates that the shape file has the required attributes. /// </summary> /// <exception cref="CriticalFileReadException">Thrown when the shape file does not have /// the required attributes.</exception> private void CheckRequiredAttributePresence() { IEnumerable <string> requiredAttributes = new[] { idAttributeName, nameAttributeName, offsetAttributeName }; foreach (string attribute in requiredAttributes) { if (!pointsShapeFileReader.HasAttribute(attribute)) { throw new CriticalFileReadException( string.Format(Resources.ProfileLocationReader_CheckRequiredAttributePresence_Missing_attribute_0_, attribute)); } } }