本文整理汇总了Python中qgis.core.QgsProjectMetadata.setKeywords方法的典型用法代码示例。如果您正苦于以下问题:Python QgsProjectMetadata.setKeywords方法的具体用法?Python QgsProjectMetadata.setKeywords怎么用?Python QgsProjectMetadata.setKeywords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.core.QgsProjectMetadata
的用法示例。
在下文中一共展示了QgsProjectMetadata.setKeywords方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testProjectMode
# 需要导入模块: from qgis.core import QgsProjectMetadata [as 别名]
# 或者: from qgis.core.QgsProjectMetadata import setKeywords [as 别名]
def testProjectMode(self):
"""
Create a fully populated QgsProjectMetadata object, then set it to the widget and re-read back
the generated metadata to ensure that no content is lost.
"""
w = QgsMetadataWidget()
m = QgsProjectMetadata()
m.setIdentifier('1234')
m.setParentIdentifier('xyz')
m.setLanguage('en-CA')
m.setType('project')
m.setTitle('roads')
m.setAbstract('my roads')
m.setHistory(['history a', 'history b'])
m.setKeywords({
'GEMET': ['kw1', 'kw2'],
'gmd:topicCategory': ['natural'],
})
c = QgsAbstractMetadataBase.Contact()
c.name = 'John Smith'
c.organization = 'ACME'
c.position = 'staff'
c.voice = '1500 515 555'
c.fax = 'xx.xxx.xxx.xxxx'
c.email = '[email protected]'
c.role = 'pointOfContact'
address = QgsAbstractMetadataBase.Address()
address.type = 'postal'
address.address = '123 Main Street'
address.city = 'anycity'
address.administrativeArea = 'anyprovince'
address.postalCode = '90210'
address.country = 'Canada'
c.addresses = [address]
m.setContacts([c])
l = QgsAbstractMetadataBase.Link()
l.name = 'geonode:roads'
l.type = 'OGC:WMS'
l.description = 'my GeoNode road layer'
l.url = 'http://example.org/wms'
l2 = QgsAbstractMetadataBase.Link()
l2.name = 'geonode:roads'
l2.type = 'OGC:WFS'
l2.description = 'my GeoNode road layer'
l2.url = 'http://example.org/wfs'
l3 = QgsAbstractMetadataBase.Link()
l3.name = 'roads'
l3.type = 'WWW:LINK'
l3.description = 'full dataset download'
l3.url = 'http://example.org/roads.tgz'
l3.format = 'ESRI Shapefile'
l3.mimeType = 'application/gzip'
l3.size = '283676'
m.setLinks([l, l2, l3])
m.setAuthor('my author')
m.setCreationDateTime(QDateTime(QDate(2001, 12, 17), QTime(9, 30, 47)))
# set widget metadata
w.setMetadata(m)
self.assertEqual(w.mode(), QgsMetadataWidget.ProjectMetadata)
m = w.metadata()
self.assertIsInstance(m, QgsProjectMetadata)
self.assertEqual(m.identifier(), '1234')
self.assertEqual(m.parentIdentifier(), 'xyz')
self.assertEqual(m.language(), 'en-CA')
self.assertEqual(m.type(), 'project')
self.assertEqual(m.title(), 'roads')
self.assertEqual(m.abstract(), 'my roads')
self.assertEqual(m.history(), ['history a', 'history b'])
self.assertEqual(
m.keywords(),
{'GEMET': ['kw1', 'kw2'], 'gmd:topicCategory': ['natural']})
self.assertEqual(m.contacts()[0].name, 'John Smith')
self.assertEqual(m.contacts()[0].organization, 'ACME')
self.assertEqual(m.contacts()[0].position, 'staff')
self.assertEqual(m.contacts()[0].voice, '1500 515 555')
self.assertEqual(m.contacts()[0].fax, 'xx.xxx.xxx.xxxx')
self.assertEqual(m.contacts()[0].email, '[email protected]')
self.assertEqual(m.contacts()[0].role, 'pointOfContact')
self.assertEqual(m.contacts()[0].addresses[0].type, 'postal')
self.assertEqual(m.contacts()[0].addresses[0].address, '123 Main Street')
self.assertEqual(m.contacts()[0].addresses[0].city, 'anycity')
self.assertEqual(m.contacts()[0].addresses[0].administrativeArea, 'anyprovince')
self.assertEqual(m.contacts()[0].addresses[0].postalCode, '90210')
self.assertEqual(m.contacts()[0].addresses[0].country, 'Canada')
self.assertEqual(m.links()[0].name, 'geonode:roads')
self.assertEqual(m.links()[0].type, 'OGC:WMS')
self.assertEqual(m.links()[0].description, 'my GeoNode road layer')
self.assertEqual(m.links()[0].url, 'http://example.org/wms')
self.assertEqual(m.links()[1].name, 'geonode:roads')
#.........这里部分代码省略.........
示例2: createTestMetadata
# 需要导入模块: from qgis.core import QgsProjectMetadata [as 别名]
# 或者: from qgis.core.QgsProjectMetadata import setKeywords [as 别名]
def createTestMetadata(self):
"""
Returns a standard metadata which can be tested with checkExpectedMetadata
"""
m = QgsProjectMetadata()
m.setIdentifier('1234')
m.setParentIdentifier('xyz')
m.setLanguage('en-CA')
m.setType('project')
m.setTitle('roads')
m.setAbstract('my roads')
m.setHistory(['history a', 'history b'])
m.setKeywords({
'GEMET': ['kw1', 'kw2'],
'gmd:topicCategory': ['natural'],
})
c = QgsAbstractMetadataBase.Contact()
c.name = 'John Smith'
c.organization = 'ACME'
c.position = 'staff'
c.voice = '1500 515 555'
c.fax = 'xx.xxx.xxx.xxxx'
c.email = '[email protected]'
c.role = 'pointOfContact'
address = QgsAbstractMetadataBase.Address()
address.type = 'postal'
address.address = '123 Main Street'
address.city = 'anycity'
address.administrativeArea = 'anyprovince'
address.postalCode = '90210'
address.country = 'Canada'
c.addresses = [address]
m.setContacts([c])
l = QgsAbstractMetadataBase.Link()
l.name = 'geonode:roads'
l.type = 'OGC:WMS'
l.description = 'my GeoNode road layer'
l.url = 'http://example.org/wms'
l2 = QgsAbstractMetadataBase.Link()
l2.name = 'geonode:roads'
l2.type = 'OGC:WFS'
l2.description = 'my GeoNode road layer'
l2.url = 'http://example.org/wfs'
l3 = QgsAbstractMetadataBase.Link()
l3.name = 'roads'
l3.type = 'WWW:LINK'
l3.description = 'full dataset download'
l3.url = 'http://example.org/roads.tgz'
l3.format = 'ESRI Shapefile'
l3.mimeType = 'application/gzip'
l3.size = '283676'
m.setLinks([l, l2, l3])
m.setAuthor('my author')
m.setCreationDateTime(QDateTime(QDate(2001, 12, 17), QTime(9, 30, 47)))
return m