@@ -2018,7 +2018,7 @@ public class XMPMeta internal constructor() {
20182018 }
20192019
20202020 /*
2021- * For missing values fall back to the Photoshop namespace .
2021+ * For missing values fall back to older places .
20222022 */
20232023
20242024 if (location.isNullOrBlank())
@@ -2062,21 +2062,28 @@ public class XMPMeta internal constructor() {
20622062 xmpLocation : XMPLocation ?
20632063 ) {
20642064
2065- /* Delete existing entries, if any */
2065+ /* Delete existing entries */
2066+
20662067 deleteProperty(XMPConst .NS_IPTC_EXT , XMPConst .XMP_IPTC_EXT_LOCATION_SHOWN )
2068+ deleteProperty(XMPConst .NS_IPTC_CORE , " Location" )
2069+ deleteProperty(XMPConst .NS_PHOTOSHOP , " City" )
2070+ deleteProperty(XMPConst .NS_PHOTOSHOP , " State" )
2071+ deleteProperty(XMPConst .NS_PHOTOSHOP , " Country" )
20672072
20682073 if (xmpLocation == null )
20692074 return
20702075
2071- /* Create a new array property. */
2076+ /*
2077+ * Write Iptc4xmpExt:LocationShown
2078+ */
2079+
20722080 setProperty(
20732081 XMPConst .NS_IPTC_EXT ,
20742082 XMPConst .XMP_IPTC_EXT_LOCATION_SHOWN ,
20752083 null ,
20762084 arrayOptions
20772085 )
20782086
2079- /* Append empty entry */
20802087 appendArrayItem(
20812088 schemaNS = XMPConst .NS_IPTC_EXT ,
20822089 arrayName = XMPConst .XMP_IPTC_EXT_LOCATION_SHOWN ,
@@ -2112,8 +2119,7 @@ public class XMPMeta internal constructor() {
21122119 )
21132120 }
21142121
2115- if (! xmpLocation.location.isNullOrBlank()) {
2116-
2122+ if (! xmpLocation.location.isNullOrBlank())
21172123 setStructField(
21182124 schemaNS = XMPConst .NS_IPTC_EXT ,
21192125 structName = XMPConst .XMP_IPTC_EXT_LOCATION_SHOWN + " [1]" ,
@@ -2122,15 +2128,7 @@ public class XMPMeta internal constructor() {
21222128 fieldValue = xmpLocation.location
21232129 )
21242130
2125- setProperty(
2126- schemaNS = XMPConst .NS_IPTC_CORE ,
2127- propName = " Location" ,
2128- propValue = xmpLocation.location
2129- )
2130- }
2131-
2132- if (! xmpLocation.city.isNullOrBlank()) {
2133-
2131+ if (! xmpLocation.city.isNullOrBlank())
21342132 setStructField(
21352133 schemaNS = XMPConst .NS_IPTC_EXT ,
21362134 structName = XMPConst .XMP_IPTC_EXT_LOCATION_SHOWN + " [1]" ,
@@ -2139,15 +2137,7 @@ public class XMPMeta internal constructor() {
21392137 fieldValue = xmpLocation.city
21402138 )
21412139
2142- setProperty(
2143- schemaNS = XMPConst .NS_PHOTOSHOP ,
2144- propName = " City" ,
2145- propValue = xmpLocation.city
2146- )
2147- }
2148-
2149- if (! xmpLocation.state.isNullOrBlank()) {
2150-
2140+ if (! xmpLocation.state.isNullOrBlank())
21512141 setStructField(
21522142 schemaNS = XMPConst .NS_IPTC_EXT ,
21532143 structName = XMPConst .XMP_IPTC_EXT_LOCATION_SHOWN + " [1]" ,
@@ -2156,15 +2146,7 @@ public class XMPMeta internal constructor() {
21562146 fieldValue = xmpLocation.state
21572147 )
21582148
2159- setProperty(
2160- schemaNS = XMPConst .NS_PHOTOSHOP ,
2161- propName = " State" ,
2162- propValue = xmpLocation.state
2163- )
2164- }
2165-
2166- if (! xmpLocation.country.isNullOrBlank()) {
2167-
2149+ if (! xmpLocation.country.isNullOrBlank())
21682150 setStructField(
21692151 schemaNS = XMPConst .NS_IPTC_EXT ,
21702152 structName = XMPConst .XMP_IPTC_EXT_LOCATION_SHOWN + " [1]" ,
@@ -2173,12 +2155,21 @@ public class XMPMeta internal constructor() {
21732155 fieldValue = xmpLocation.country
21742156 )
21752157
2176- setProperty(
2177- schemaNS = XMPConst .NS_PHOTOSHOP ,
2178- propName = " Country" ,
2179- propValue = xmpLocation.country
2180- )
2181- }
2158+ /*
2159+ * Write older fields for completeness
2160+ */
2161+
2162+ if (! xmpLocation.location.isNullOrBlank())
2163+ setProperty(XMPConst .NS_IPTC_CORE , " Location" , xmpLocation.location)
2164+
2165+ if (! xmpLocation.city.isNullOrBlank())
2166+ setProperty(XMPConst .NS_PHOTOSHOP , " City" , xmpLocation.city)
2167+
2168+ if (! xmpLocation.state.isNullOrBlank())
2169+ setProperty(XMPConst .NS_PHOTOSHOP , " State" , xmpLocation.state)
2170+
2171+ if (! xmpLocation.country.isNullOrBlank())
2172+ setProperty(XMPConst .NS_PHOTOSHOP , " Country" , xmpLocation.country)
21822173 }
21832174
21842175 public fun getTitle (): String? {
0 commit comments