Exemplo n.º 1
0
 /**
  * `save` should import KML from the "Coverage" element.
  */
 public function testImportDublinCoreKml()
 {
     $this->_skipIfPlugin('NeatlineFeatures');
     $exhibit = $this->_exhibit();
     $item = $this->_item();
     $this->_addCoverageElement($item, self::KML);
     $record = new NeatlineRecord($exhibit, $item);
     $record->save();
     // Should import KML and convert to WKT.
     $this->assertEquals(nl_getWkt(self::KML), $record->coverage);
 }
Exemplo n.º 2
0
 /**
  * If the passed value is neither WKT nor KML, return null.
  */
 public function testIgnoreInvalid()
 {
     $this->assertNull(nl_getWkt('Paris'));
 }
Exemplo n.º 3
0
 /**
  * Import coverage from Neatline Features, if it's installed, and set the
  * `is_coverage` flag.
  */
 public function compileCoverage()
 {
     $item = $this->getItem();
     // Only try to import coverage values if (a) a parent item is defined
     // and (b) the local coverage value is currently empty (this prevents
     // modified coverages from being overwritten on save).
     if ($item && !$this->coverage) {
         if (plugin_is_active('NeatlineFeatures')) {
             // Try to import a value from Neatline Features.
             $wkt = nl_getNeatlineFeaturesWkt($this);
             if (is_string($wkt)) {
                 $this->coverage = $wkt;
             }
         }
         if (!$this->coverage) {
             // If a coverage wasn't gethered from Features (either because
             // it isn't installed, or there isn't a Features-managed value
             // for the item), just look for a vanilla DC "Coverage" value.
             try {
                 // Try to get a DC "Coverage" value.
                 $coverage = metadata($item, array('Dublin Core', 'Coverage'));
                 // Try to convert it to WKT.
                 $this->coverage = nl_getWkt($coverage);
             } catch (Exception $e) {
             }
         }
     }
     // Track if a coverage is present.
     $this->is_coverage = $this->coverage ? 1 : 0;
 }