Commit 3681bfcc8ddfdc449bccac14433674e74ded3a12
1 parent
c44aeecf
Exists in
master
and in
7 other branches
Corrige a leitura de geoRSS
Showing
3 changed files
with
44 additions
and
44 deletions
Show diff stats
classesphp/classe_mapa.php
| ... | ... | @@ -1570,30 +1570,32 @@ $canal - Identificador do canal (ordem em que está no RSS) |
| 1570 | 1570 | { |
| 1571 | 1571 | $xml = simplexml_load_file($servico); |
| 1572 | 1572 | $conta = 0; |
| 1573 | - foreach($xml->channel as $c) | |
| 1574 | - { | |
| 1573 | + foreach($xml->channel as $c){ | |
| 1575 | 1574 | if ($conta == $canal) |
| 1576 | 1575 | {$canal = $c;} |
| 1577 | 1576 | } |
| 1578 | 1577 | $resultado = array(); |
| 1579 | 1578 | $tipog = ""; |
| 1580 | - foreach ($canal->item as $item) | |
| 1581 | - { | |
| 1579 | + foreach ($canal->item as $item){ | |
| 1582 | 1580 | $env = array(); |
| 1583 | 1581 | //define o tipo |
| 1584 | - if ($item->xpath('geo:lat')){$tipog = "geo";} | |
| 1585 | - if ($item->xpath('georss:point')){$tipog = "georsspoint";} | |
| 1586 | - if ($item->xpath('georss:where')){$tipog = "envelope";} | |
| 1587 | - if ($tipog == "envelope") | |
| 1588 | - { | |
| 1582 | + if ($item->xpath('geo:lat')) | |
| 1583 | + {$tipog = "geo";} | |
| 1584 | + if ($item->xpath('georss:point')) | |
| 1585 | + {$tipog = "georsspoint";} | |
| 1586 | + if ($item->xpath('georss:where')) | |
| 1587 | + {$tipog = "envelope";} | |
| 1588 | + if ($tipog == "envelope"){ | |
| 1589 | 1589 | foreach ($item->xpath('georss:where') as $w) |
| 1590 | 1590 | { |
| 1591 | 1591 | foreach ($w->xpath('gml:Envelope') as $e) |
| 1592 | 1592 | { |
| 1593 | - $lc = $e->xpath('gml:lowerCorner'); | |
| 1594 | - $uc = $e->xpath('gml:upperCorner'); | |
| 1595 | - $lc = explode(" ",$lc[0]); | |
| 1596 | - $uc = explode(" ",$uc[0]); | |
| 1593 | + //$lc = $e->xpath('gml:lowerCorner'); | |
| 1594 | + $lc = (string) $e->children('gml', TRUE)->lowerCorner; | |
| 1595 | + //$uc = $e->xpath('gml:upperCorner'); | |
| 1596 | + $uc = (string) $e->children('gml', TRUE)->upperCorner; | |
| 1597 | + $lc = explode(" ",$lc); | |
| 1598 | + $uc = explode(" ",$uc); | |
| 1597 | 1599 | if (is_numeric($lc[0])) |
| 1598 | 1600 | { |
| 1599 | 1601 | $ymin = $lc[0]; |
| ... | ... | @@ -1606,33 +1608,32 @@ $canal - Identificador do canal (ordem em que está no RSS) |
| 1606 | 1608 | } |
| 1607 | 1609 | } |
| 1608 | 1610 | } |
| 1609 | - if ($tipog == "geo") | |
| 1610 | - { | |
| 1611 | - if ($item->xpath('geo:lon')) | |
| 1612 | - {$x = $item->xpath('geo:lon');} | |
| 1613 | - else | |
| 1614 | - {$x = $item->xpath('geo:long');} | |
| 1615 | - $y = $item->xpath('geo:lat'); | |
| 1616 | - $env = array($y[0],$x[0]); | |
| 1611 | + if ($tipog == "geo"){ | |
| 1612 | + if ($item->xpath('geo:lon')){ | |
| 1613 | + $x = (string) $item->children('geo', TRUE)->lon; | |
| 1614 | + } | |
| 1615 | + else{ | |
| 1616 | + $x = (string) $item->children('geo', TRUE)->long; | |
| 1617 | + } | |
| 1618 | + //$y = $item->xpath('geo:lat'); | |
| 1619 | + $y = (string) $item->children('geo', TRUE)->lat; | |
| 1620 | + $env = array($y,$x); | |
| 1621 | + | |
| 1617 | 1622 | } |
| 1618 | 1623 | if ($tipog == "georsspoint") |
| 1619 | 1624 | { |
| 1620 | - $temp = $item->xpath('georss:point'); | |
| 1621 | - $env = array( explode(" ",$temp[0]) ); | |
| 1625 | + //$temp = $item->xpath('georss:point'); | |
| 1626 | + $temp = (string) $item->children('georss', TRUE)->point; | |
| 1627 | + $env = array( explode(" ",$temp) ); | |
| 1622 | 1628 | } |
| 1623 | - if (count($env) > 0) | |
| 1624 | - { | |
| 1629 | + if (count($env) > 0){ | |
| 1625 | 1630 | $resultado[] = array(ixml($item,"title"),ixml($item,"link"),ixml($item,"description"),ixml($item,"category"),$env); |
| 1626 | 1631 | } |
| 1627 | 1632 | } |
| 1628 | 1633 | //cria o shapefile com os dados |
| 1629 | - if (count($resultado) > 0) | |
| 1630 | - { | |
| 1634 | + if (count($resultado) > 0){ | |
| 1631 | 1635 | //para manipular dbf |
| 1632 | - if (file_exists($this->locaplic."/pacotes/phpxbase/api_conversion.php")) | |
| 1633 | - include_once ($this->locaplic."/pacotes/phpxbase/api_conversion.php"); | |
| 1634 | - else | |
| 1635 | - include_once ("../pacotes/phpxbase/api_conversion.php"); | |
| 1636 | + include_once (__DIR__."/../pacotes/phpxbase/api_conversion.php"); | |
| 1636 | 1637 | $diretorio = dirname($this->arquivo); |
| 1637 | 1638 | $tipol = MS_SHP_POLYGON; |
| 1638 | 1639 | if ($tipog == "georsspoint"){$tipol = MS_SHP_POINT;} |
| ... | ... | @@ -1654,11 +1655,9 @@ $canal - Identificador do canal (ordem em que está no RSS) |
| 1654 | 1655 | $reg = array(); |
| 1655 | 1656 | $novoshpf = ms_newShapefileObj($nomeshp.".shp", -2); |
| 1656 | 1657 | //acrescenta os shapes |
| 1657 | - foreach ($resultado as $r) | |
| 1658 | - { | |
| 1658 | + foreach ($resultado as $r){ | |
| 1659 | 1659 | $pts = $r[4]; |
| 1660 | - if ($tipol == MS_SHP_POLYGON) | |
| 1661 | - { | |
| 1660 | + if ($tipol == MS_SHP_POLYGON){ | |
| 1662 | 1661 | $shp = ms_newShapeObj(MS_SHP_POLYGON); |
| 1663 | 1662 | $linha = ms_newLineObj(); |
| 1664 | 1663 | $linha->addXY($pts[0],$pts[3]); |
| ... | ... | @@ -1667,8 +1666,7 @@ $canal - Identificador do canal (ordem em que está no RSS) |
| 1667 | 1666 | $linha->addXY($pts[0],$pts[1]); |
| 1668 | 1667 | $linha->addXY($pts[0],$pts[3]); |
| 1669 | 1668 | } |
| 1670 | - else | |
| 1671 | - { | |
| 1669 | + else{ | |
| 1672 | 1670 | $shp = ms_newShapeObj(MS_SHP_POINT); |
| 1673 | 1671 | $linha = ms_newLineObj(); |
| 1674 | 1672 | $linha->addXY($pts[1],$pts[0]); |
| ... | ... | @@ -1680,10 +1678,13 @@ $canal - Identificador do canal (ordem em que está no RSS) |
| 1680 | 1678 | $reg = array(); |
| 1681 | 1679 | } |
| 1682 | 1680 | xbase_close($db); |
| 1683 | - if ($tipog == "georsspoint" || $tipog == "geo") | |
| 1684 | - {$tipol = MS_LAYER_POINT;} | |
| 1685 | - else | |
| 1686 | - {$tipol = MS_LAYER_POLYGON;} | |
| 1681 | + if ($tipog == "georsspoint" || $tipog == "geo"){ | |
| 1682 | + $tipol = MS_LAYER_POINT; | |
| 1683 | + } | |
| 1684 | + else{ | |
| 1685 | + $tipol = MS_LAYER_POLYGON; | |
| 1686 | + } | |
| 1687 | + | |
| 1687 | 1688 | $layer = criaLayer($this->mapa,$tipol,MS_DEFAULT,"GeoRSS","SIM"); |
| 1688 | 1689 | $layer->set("data",$nomeshp.".shp"); |
| 1689 | 1690 | $layer->set("name",basename($nomeshp)); | ... | ... |
ferramentas/conectargeorss/exec.php
| ... | ... | @@ -20,8 +20,7 @@ Adiciona um tema baseado em um RSS. |
| 20 | 20 | $retorno = $m->adicionaTemaGeoRSS($servico,$dir_tmp,$locaplic,$canal); |
| 21 | 21 | if ($retorno != "erro") |
| 22 | 22 | {$m->salva();$_SESSION["contadorsalva"]++;redesenhaMapa();} |
| 23 | - else | |
| 24 | - { | |
| 23 | + else{ | |
| 25 | 24 | $retorno = "erro.Nenhum dado espacializado foi encontrado."; |
| 26 | 25 | } |
| 27 | 26 | break; | ... | ... |
ferramentas/conectargeorss/index.js
| ... | ... | @@ -99,7 +99,7 @@ retorno {JSON} - retorno da função clickGuia2 |
| 99 | 99 | */ |
| 100 | 100 | function listaCanais(retorno) |
| 101 | 101 | { |
| 102 | - var i,ins = "Clique no botão 'mapa' para incluir os dados do canal desejado<br>"; | |
| 102 | + var i,ins = "Escolha um dos itens para incluir os dados do canal no mapa<br>"; | |
| 103 | 103 | if (retorno.data != undefined) |
| 104 | 104 | { |
| 105 | 105 | retorno = retorno.data; | ... | ... |