Plugin Directory

Changeset 1607853


Ignore:
Timestamp:
03/04/2017 03:58:25 PM (9 years ago)
Author:
stuporglue
Message:

Prepping for release 0.3.2

Location:
wp-geometa
Files:
87 added
16 deleted
21 edited

Legend:

Unmodified
Added
Removed
  • wp-geometa/trunk/CHANGELOG.md

    r1557784 r1607853  
    11Changes
    22-------
     3
     4### 0.3.2
     5 * Update to wp-geometa-lib 0.3.2.
     6 * Updated internal filter callback function names to match the filter they're for.
     7 * Updated branding to reflect company name change.
     8 * Updated handling if submodules aren't checked out.
    39
    410### 0.3.1
  • wp-geometa/trunk/lang/wp-geometa-pt_BR.po

    r1488557 r1607853  
    22msgstr ""
    33"Project-Id-Version: WP-GeoMeta\n"
    4 "POT-Creation-Date: 2016-08-24 11:43-0500\n"
    5 "PO-Revision-Date: 2016-08-24 11:47-0500\n"
     4"POT-Creation-Date: 2017-03-01 02:08-0600\n"
     5"PO-Revision-Date: 2017-03-01 02:08-0600\n"
    66"Last-Translator: \n"
    77"Language-Team: \n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "X-Generator: Poedit 1.8.8\n"
     12"X-Generator: Poedit 1.8.11\n"
    1313"X-Poedit-Basepath: ..\n"
    1414"Plural-Forms: nplurals=2; plural=(n > 1);\n"
     
    1919"X-Poedit-SearchPath-1: .\n"
    2020
    21 #: lib/wp-geometa-dash.php:45
     21#: lib/wp-geometa-dash.php:54
    2222msgid "Spatial Relationship Tests"
    2323msgstr "Testes Relação Espacial"
    2424
    25 #: lib/wp-geometa-dash.php:46
     25#: lib/wp-geometa-dash.php:55
    2626msgid "Test topological relationships between two geometries."
    2727msgstr "Teste relações topológicas entre duas geometrias."
    2828
    29 #: lib/wp-geometa-dash.php:80
     29#: lib/wp-geometa-dash.php:89
    3030msgid "Geometry Properties"
    3131msgstr "Propriedades de Geometria"
    3232
    33 #: lib/wp-geometa-dash.php:81
     33#: lib/wp-geometa-dash.php:90
    3434msgid "Analyize spatial properties of a single geometry."
    3535msgstr "Analisar propriedades de uma geometria."
    3636
    37 #: lib/wp-geometa-dash.php:104
     37#: lib/wp-geometa-dash.php:113
    3838msgid "Geometry Disection"
    3939msgstr "Dissecação de Geometria"
    4040
    41 #: lib/wp-geometa-dash.php:105
     41#: lib/wp-geometa-dash.php:114
    4242msgid "Investigate the type and sub-parts of a geometry."
    4343msgstr "Pesquisar o tipo e sub-partes de uma geometria."
    4444
    45 #: lib/wp-geometa-dash.php:135
     45#: lib/wp-geometa-dash.php:144
    4646msgid "Generate new Geometry"
    4747msgstr "Gerar novo Geometria"
    4848
    49 #: lib/wp-geometa-dash.php:136
     49#: lib/wp-geometa-dash.php:145
    5050msgid ""
    5151"Create a new geometry based on existing geometries and spatial operations."
     
    5454"espaciais."
    5555
    56 #: lib/wp-geometa-dash.php:157
     56#: lib/wp-geometa-dash.php:166
    5757msgid "Data Format Helpers"
    5858msgstr "Ajudantes de Formatar Dados"
    5959
    60 #: lib/wp-geometa-dash.php:158
     60#: lib/wp-geometa-dash.php:167
    6161msgid "Create or convert geometries from various input and output formats."
    6262msgstr "Criar ou converter geometrias de vários formas de entrada e saída."
    6363
    64 #: lib/wp-geometa-dash.php:229
     64#: lib/wp-geometa-dash.php:238
    6565msgid "Miscellaneous Functions"
    6666msgstr "Funções Diversas"
    6767
    68 #: lib/wp-geometa-dash.php:230
     68#: lib/wp-geometa-dash.php:239
    6969msgid "Other little-used functions."
    7070msgstr "Outros funções poucos usados."
    7171
    72 #: lib/wp-geometa-dash.php:296
     72#: lib/wp-geometa-dash.php:252
     73msgid "Custom Functions"
     74msgstr ""
     75
     76#: lib/wp-geometa-dash.php:253
     77msgid ""
     78"These are custom functions, usually written in SQL using `CREATE FUNCTION` "
     79"statements. They will probably be slower than native functions."
     80msgstr ""
     81
     82#: lib/wp-geometa-dash.php:317
    7383#, php-format
    7484msgid "Are you sure you want to %1$s?"
    7585msgstr "Tem certeza que você quer %1$s?"
    7686
    77 #: lib/wp-geometa-dash.php:322
     87#: lib/wp-geometa-dash.php:343
    7888msgid "Your Data"
    7989msgstr "Seus Dados"
    8090
    81 #: lib/wp-geometa-dash.php:323 lib/wp-geometa-dash.php:860
    82 #: lib/wp-geometa-dash.php:889
     91#: lib/wp-geometa-dash.php:344 lib/wp-geometa-dash.php:917
     92#: lib/wp-geometa-dash.php:946
    8393msgid "Quick Start"
    8494msgstr "Inicio Rapido"
    8595
    86 #: lib/wp-geometa-dash.php:324
     96#: lib/wp-geometa-dash.php:345
    8797msgid "Your Functions"
    8898msgstr "Seus Funções"
    8999
    90 #: lib/wp-geometa-dash.php:325
     100#: lib/wp-geometa-dash.php:346
    91101msgid "Resources"
    92102msgstr "Recursos"
    93103
    94 #: lib/wp-geometa-dash.php:326 lib/wp-geometa-dash.php:860
     104#: lib/wp-geometa-dash.php:347 lib/wp-geometa-dash.php:917
    95105msgid "System Status"
    96106msgstr "Status do Sistema"
    97107
    98 #: lib/wp-geometa-dash.php:390
     108#: lib/wp-geometa-dash.php:411
    99109msgid "Geo Tables Exist!"
    100110msgstr "Tabelas Geo Existem!"
    101111
    102 #: lib/wp-geometa-dash.php:390
     112#: lib/wp-geometa-dash.php:411
    103113msgid "All geometa tables exist."
    104114msgstr "Todos as tabelas de geometa existem."
    105115
    106 #: lib/wp-geometa-dash.php:392
     116#: lib/wp-geometa-dash.php:413
    107117msgid "Some Geo Tables Exist"
    108118msgstr "Algumas Tabelas Geo Existem"
    109119
    110 #: lib/wp-geometa-dash.php:392
     120#: lib/wp-geometa-dash.php:413
    111121#, php-format
    112122msgid ""
     
    117127"ter uma problema. %1$s existem. %2$s não existem."
    118128
    119 #: lib/wp-geometa-dash.php:394
     129#: lib/wp-geometa-dash.php:415
    120130msgid "No Geo Tables Exist!"
    121131msgstr "Nenhum Tabela Geo Existe!"
    122132
    123 #: lib/wp-geometa-dash.php:394
     133#: lib/wp-geometa-dash.php:415
    124134msgid ""
    125135"No geo tables exist. You can try recreating them with the tools at the "
     
    129139"deste pagina."
    130140
    131 #: lib/wp-geometa-dash.php:418
     141#: lib/wp-geometa-dash.php:439
    132142msgid "Geo Tables Indexed!"
    133143msgstr "Tabelas Geo Indexado!"
    134144
    135 #: lib/wp-geometa-dash.php:418
     145#: lib/wp-geometa-dash.php:439
    136146#, php-format
    137147msgid "All %1$s geometa tables have spatial indexes"
    138148msgstr "Todas as %1$s tabelas geometa tem índices espaciais"
    139149
    140 #: lib/wp-geometa-dash.php:420
     150#: lib/wp-geometa-dash.php:441
    141151msgid "Some Geo Tables Not Indexed"
    142152msgstr "Algumas tabelas geo não indexados"
    143153
    144 #: lib/wp-geometa-dash.php:420
     154#: lib/wp-geometa-dash.php:441
    145155#, php-format
    146156msgid ""
     
    151161"lento nos seguintes tabelas: %1$s"
    152162
    153 #: lib/wp-geometa-dash.php:422
     163#: lib/wp-geometa-dash.php:443
    154164msgid "No Spatial Indexes!"
    155165msgstr "Nenhum Índice Espacial!"
    156166
    157 #: lib/wp-geometa-dash.php:422
     167#: lib/wp-geometa-dash.php:443
    158168msgid "No spatial indexes found. Spatial queries will be slow."
    159169msgstr "Nenhum Índice espacial encontrado. Pesquisas espaciais vão ser lentos."
    160170
    161 #: lib/wp-geometa-dash.php:436
     171#: lib/wp-geometa-dash.php:457
    162172msgid "Good Database Version!"
    163173msgstr "Banco de Dados Versão Boa!"
    164174
    165 #: lib/wp-geometa-dash.php:436
     175#: lib/wp-geometa-dash.php:457
    166176#, php-format
    167177msgid ""
     
    171181"Seu versão de banco de dados (%1$s) suporte vários funções espaciais úteis."
    172182
    173 #: lib/wp-geometa-dash.php:438
     183#: lib/wp-geometa-dash.php:459
    174184msgid "OK Database Version"
    175185msgstr "Banco de Dados Versão OK"
    176186
    177 #: lib/wp-geometa-dash.php:438
     187#: lib/wp-geometa-dash.php:459
    178188#, php-format
    179189msgid ""
     
    186196"ou MariaDB 5.3.3 ou superior."
    187197
    188 #: lib/wp-geometa-dash.php:440
     198#: lib/wp-geometa-dash.php:461
    189199msgid "Bad Database Version!"
    190200msgstr "Banco de Dados Versão Ruim!"
    191201
    192 #: lib/wp-geometa-dash.php:440
     202#: lib/wp-geometa-dash.php:461
    193203#, php-format
    194204msgid ""
     
    199209"não poderia guardar ou utilizar dados espaciais."
    200210
    201 #: lib/wp-geometa-dash.php:461
     211#: lib/wp-geometa-dash.php:495
     212msgid "Odd Situation!"
     213msgstr ""
     214
     215#: lib/wp-geometa-dash.php:495
     216#, php-format
     217msgid ""
     218"You have the latest version of WP-GeoMeta, but another plugin is providing "
     219"an older version WP-GeoMeta-Lib Please update the plugin(s) not providing "
     220"version %1$s in the list below!"
     221msgstr ""
     222
     223#: lib/wp-geometa-dash.php:500
    202224msgid "Up To Date!"
    203225msgstr "Atualizado!"
    204226
    205 #: lib/wp-geometa-dash.php:461
    206 #, php-format
    207 msgid "You are running the most recent version of WP GeoMeta (%1$s)."
    208 msgstr "Você esta usando o versão mais recente de WP GeoMeta (%1$s)."
    209 
    210 #: lib/wp-geometa-dash.php:463
     227#: lib/wp-geometa-dash.php:500
     228#, php-format
     229msgid "You are using the most recent version of WP-GeoMeta-Lib (%1$s)."
     230msgstr ""
     231
     232#: lib/wp-geometa-dash.php:506
    211233msgid "Out Of Date."
    212234msgstr "Desactualizado."
    213235
    214 #: lib/wp-geometa-dash.php:463
    215 #, php-format
    216 msgid ""
    217 "A plugin you are using is providing the most recent version of the WP "
    218 "GeoMeta library (%1$s), but this plugin is out of date."
    219 msgstr ""
    220 "Um plugin você esta usando esta providenciando o versão mais recente do "
    221 "módulo WP GeoMeta (%1$s), mas este plugin esta desactualizado."
    222 
    223 #: lib/wp-geometa-dash.php:465
     236#: lib/wp-geometa-dash.php:506
     237#, php-format
     238msgid ""
     239"A plugin you are using is providing the most recent version of the WP-"
     240"GeoMeta-Lib (%1$s), but this plugin is out of date."
     241msgstr ""
     242
     243#: lib/wp-geometa-dash.php:511
    224244msgid "Out Of Date!"
    225245msgstr "Desactualizado!"
    226246
    227 #: lib/wp-geometa-dash.php:465
    228 #, php-format
    229 msgid ""
    230 "You are running an outdated version of WP GeoMeta (%1$s). Please upgrade!"
    231 msgstr ""
    232 "Você esta usando um versão desatualizado de WP GeoMeta (%1$s). Atualiza "
    233 "porfavor!"
    234 
    235 #: lib/wp-geometa-dash.php:518
     247#: lib/wp-geometa-dash.php:511
     248#, php-format
     249msgid ""
     250"You are running an outdated version of WP-GeoMeta-Lib (%1$s). Please upgrade "
     251"to %2$s!"
     252msgstr ""
     253
     254#: lib/wp-geometa-dash.php:564
    236255msgid "All Spatial Data Loaded!"
    237256msgstr "Todos os dados espaciais carregado!"
    238257
    239 #: lib/wp-geometa-dash.php:518
     258#: lib/wp-geometa-dash.php:564
    240259#, php-format
    241260msgid "All %1$s spatial records are loaded!"
    242261msgstr "Todos os %1$s recordes espaciais foram carregado!"
    243262
    244 #: lib/wp-geometa-dash.php:520
     263#: lib/wp-geometa-dash.php:566
    245264msgid "Some Spatial Data Loaded"
    246265msgstr "Algumas dados espaciais carregado!"
    247266
    248 #: lib/wp-geometa-dash.php:520
     267#: lib/wp-geometa-dash.php:566
    249268#, php-format
    250269msgid ""
     
    255274"carregados). Tenta usa o ferimento %3$s%4$s%5$s para carregá-los."
    256275
    257 #: lib/wp-geometa-dash.php:520 lib/wp-geometa-dash.php:522
    258 #: lib/wp-geometa-dash.php:1061
    259 msgid "Populate WP GeoMeta Tables"
    260 msgstr "Popular as tabelas WP GeoMeta"
    261 
    262 #: lib/wp-geometa-dash.php:522
     276#: lib/wp-geometa-dash.php:566 lib/wp-geometa-dash.php:568
     277#: lib/wp-geometa-dash.php:1124
     278msgid "Populate WP-GeoMeta Tables"
     279msgstr ""
     280
     281#: lib/wp-geometa-dash.php:568
    263282msgid "No Spatial Data Loaded!"
    264283msgstr "Nenhum Dados Espacial Carregado!"
    265284
    266 #: lib/wp-geometa-dash.php:522
     285#: lib/wp-geometa-dash.php:568
    267286#, php-format
    268287msgid ""
     
    273292"ferramenta %1$s%2$s%3$s em baixo para carregar os dados."
    274293
    275 #: lib/wp-geometa-dash.php:802
    276 msgid "The WP GeoMeta tables should be gone now."
    277 msgstr "As tabelas WP GeoMeta devem ser ido agora."
    278 
    279 #: lib/wp-geometa-dash.php:807
    280 msgid "The WP GeoMeta tables should exist now."
    281 msgstr "As tabelas WP GeoMeta devem existir agora."
    282 
    283 #: lib/wp-geometa-dash.php:812
    284 msgid "The WP GeoMeta tables should be empty now."
    285 msgstr "As tabelas WP GeoMeta devem estar vazios agora."
    286 
    287 #: lib/wp-geometa-dash.php:818
    288 msgid "The WP GeoMeta tables should be populated now."
    289 msgstr "As tabelas WP GeoMeta devem estar preenchido agora."
    290 
    291 #: lib/wp-geometa-dash.php:821
     294#: lib/wp-geometa-dash.php:847
     295msgid "The WP-GeoMeta tables should be gone now."
     296msgstr ""
     297
     298#: lib/wp-geometa-dash.php:852
     299msgid "The WP-GeoMeta tables and functions should exist now."
     300msgstr ""
     301
     302#: lib/wp-geometa-dash.php:857
     303msgid "The WP-GeoMeta tables should be empty now."
     304msgstr ""
     305
     306#: lib/wp-geometa-dash.php:863
     307msgid "The WP-GeoMeta tables should be populated now."
     308msgstr ""
     309
     310#: lib/wp-geometa-dash.php:867
     311msgid "The cache of spatial functions should be rebuilt now."
     312msgstr ""
     313
     314#: lib/wp-geometa-dash.php:870
    292315msgid "I don't understand what I'm supposed to do."
    293316msgstr "Eu não entendo que eu devo fazer."
    294317
    295 #: lib/wp-geometa-dash.php:854
     318#: lib/wp-geometa-dash.php:903
    296319msgid "Your Spatial Data"
    297320msgstr "Seus Dados Espaciais."
    298321
    299 #: lib/wp-geometa-dash.php:855
     322#: lib/wp-geometa-dash.php:912
    300323msgid "Found Spatial Metadata Types"
    301324msgstr "Tipos de Metadados Espaciais Encontrados"
    302325
    303 #: lib/wp-geometa-dash.php:860
     326#: lib/wp-geometa-dash.php:917
    304327#, php-format
    305328msgid ""
     
    312335"%6$s."
    313336
    314 #: lib/wp-geometa-dash.php:863
     337#: lib/wp-geometa-dash.php:920
    315338msgid "Type"
    316339msgstr "Tipo"
    317340
    318 #: lib/wp-geometa-dash.php:864
     341#: lib/wp-geometa-dash.php:921
    319342msgid "Meta Key"
    320343msgstr "Chave Meta"
    321344
    322 #: lib/wp-geometa-dash.php:865
     345#: lib/wp-geometa-dash.php:922
    323346msgid "Number of Records"
    324347msgstr "Número de Recordes"
    325348
    326 #: lib/wp-geometa-dash.php:866
     349#: lib/wp-geometa-dash.php:923
    327350msgid "View Sample Data (500 records max)"
    328351msgstr "Veja Amostra De Dados (500 recordes no máximo)"
    329352
    330 #: lib/wp-geometa-dash.php:874
     353#: lib/wp-geometa-dash.php:931
    331354msgid "View Data"
    332355msgstr "Veja Dados"
    333356
    334 #: lib/wp-geometa-dash.php:891
    335 msgid ""
    336 "WP GeoMeta uses the standard WordPress metadata functions. If you are "
    337 "familiar with these functions, you already know how to use WP GeoMeta."
    338 msgstr ""
    339 "WP GeoMeta usa os funções WordPress metadata padrão. Se você já tem "
    340 "familiaridade com estes funções, você ja sabe como usar o WP GeoMeta."
    341 
    342 #: lib/wp-geometa-dash.php:893
    343 msgid ""
    344 "WP GeoMeta watches for GeoJSON metadata values being saved to the database. "
     357#: lib/wp-geometa-dash.php:948
     358msgid ""
     359"WP-GeoMeta uses the standard WordPress metadata functions. If you are "
     360"familiar with these functions, you already know how to use WP-GeoMeta."
     361msgstr ""
     362
     363#: lib/wp-geometa-dash.php:950
     364msgid ""
     365"WP-GeoMeta watches for GeoJSON metadata values being saved to the database. "
    345366"It saves the GeoJSON like WordPress expects, but also converts the GeoJSON "
    346367"into a spatial format MySQL understands and saves that to special geo-meta "
    347368"tables which can handle spatial data and which have spatial indexes."
    348369msgstr ""
    349 "WP GeoMeta fica de olho para valores metadados tipo GeoJSON sendo guardados "
    350 "no banco de dados. O escreve o GeoJSON como WordPress espera, mas também "
    351 "converta o GeoJSON em um formato espaciais que MySQL compreende, e guarda "
    352 "aquele em tabelas especiais de geo-meta que podem utilizar dados espaciais e "
    353 "que tem índices espaciais."
    354 
    355 #: lib/wp-geometa-dash.php:895
     370
     371#: lib/wp-geometa-dash.php:952
    356372msgid "Adding and Updating Data"
    357373msgstr "Adição e Atualização de Dados"
    358374
    359 #: lib/wp-geometa-dash.php:896
     375#: lib/wp-geometa-dash.php:953
    360376msgid ""
    361377"To add spatial data, use the usual add_post_meta or update_post_meta "
     
    367383"GeoJSON para o valor. "
    368384
    369 #: lib/wp-geometa-dash.php:909
     385#: lib/wp-geometa-dash.php:966
    370386msgid "Fetching and Using Data"
    371387msgstr "Buscando e Usando Dados"
    372388
    373 #: lib/wp-geometa-dash.php:911
    374 msgid ""
    375 "WP GeoMeta doesn't do anything when fetching data. You will get back the "
     389#: lib/wp-geometa-dash.php:968
     390msgid ""
     391"WP-GeoMeta doesn't do anything when fetching data. You will get back the "
    376392"same GeoJSON value that you stored previously."
    377393msgstr ""
    378 "WP GeoMeta não faz nada quando buscando dados. Você receberá o mesmo valor "
    379 "de GeoJSON que você adicionou anteriormente."
    380 
    381 #: lib/wp-geometa-dash.php:912
     394
     395#: lib/wp-geometa-dash.php:969
    382396msgid ""
    383397"GeoJSON can be used by any of the popular web map software available today."
     
    386400"hoje."
    387401
    388 #: lib/wp-geometa-dash.php:920
     402#: lib/wp-geometa-dash.php:977
    389403msgid "Running Spatial Queries"
    390404msgstr "Executando Consultas Espaciais"
    391405
    392 #: lib/wp-geometa-dash.php:922
     406#: lib/wp-geometa-dash.php:979
    393407msgid ""
    394408"The real power of GIS and Spatial data becomes evident when you start doing "
    395 "real spatial searches. WP GeoMeta integrates with WP_Query, get_posts and "
     409"real spatial searches. WP-GeoMeta integrates with WP_Query, get_posts and "
    396410"other functions that use WP_Meta_Query under the hood."
    397411msgstr ""
    398 "O verdadero pode de SIG e dados espaciais se tornam evidente quando você "
    399 "começa a fazer buscas espaciais reais. WP GeoMeta integra com WP_Query, "
    400 "get_posts e outros funções que usam WP_Meta_Query sob o capô."
    401 
    402 #: lib/wp-geometa-dash.php:961
     412
     413#: lib/wp-geometa-dash.php:1018
    403414msgid "Available Spatial Functions"
    404415msgstr "Funções Espaciais Disponíveis"
    405416
    406 #: lib/wp-geometa-dash.php:962
     417#: lib/wp-geometa-dash.php:1019
    407418msgid "These functions are available in this version of MySQL."
    408419msgstr "Estes funções estão disponíveis em este versão de MySQL."
    409420
    410 #: lib/wp-geometa-dash.php:963
     421#: lib/wp-geometa-dash.php:1020
    411422#, php-format
    412423msgid ""
     
    419430"um analise completa."
    420431
    421 #: lib/wp-geometa-dash.php:964
     432#: lib/wp-geometa-dash.php:1021
    422433msgid "Function Group"
    423434msgstr "Grupo de Funções"
    424435
    425 #: lib/wp-geometa-dash.php:964
     436#: lib/wp-geometa-dash.php:1021
    426437msgid "Functions"
    427438msgstr "Funções"
    428439
    429 #: lib/wp-geometa-dash.php:978
     440#: lib/wp-geometa-dash.php:1035
    430441msgid "List of Installs"
    431442msgstr "Lista de Instalações"
    432443
    433 #: lib/wp-geometa-dash.php:979
    434 msgid ""
    435 "WP GeoMeta can be installed as a plugin or used as a library by other "
    436 "plugins. This list includes all installed versions of WP GeoMeta and which "
    437 "plugin they came with."
    438 msgstr ""
    439 "WP GeoMeta pode ser instalado como um plugin ou utilizado como um biblioteca "
    440 "por outros plugins. Este lista inclui todos os versões de WP GeoMeta "
    441 "installados e com qual plugin eles foram incluídos."
    442 
    443 #: lib/wp-geometa-dash.php:980
    444 msgid ""
    445 "WP GeoMeta always uses the most up to date version installed, even if a "
     444#: lib/wp-geometa-dash.php:1036
     445msgid ""
     446"The WP-GeoMeta-Lib library may be used by multiple plugins. This list "
     447"includes all installed versions of WP-GeoMeta-Lib and which plugin they came "
     448"with."
     449msgstr ""
     450
     451#: lib/wp-geometa-dash.php:1037
     452msgid ""
     453"WP-GeoMeta always uses the most up to date version installed, even if a "
    446454"plugin bundles an older version."
    447455msgstr ""
    448 "WP GeoMeta sempre usa o versão mais recente instalado, mesmo se um plugin "
    449 "inclue um versão mais velho."
    450 
    451 #: lib/wp-geometa-dash.php:982
     456
     457#: lib/wp-geometa-dash.php:1039
    452458msgid "Plugin Name"
    453459msgstr "Nome do Plugin"
    454460
    455 #: lib/wp-geometa-dash.php:982
    456 msgid "WP GeoMeta Version"
    457 msgstr "Versão de WP GeoMeta"
    458 
    459 #: lib/wp-geometa-dash.php:995
    460 msgid "WP GeoMeta Meta and Resources"
    461 msgstr "WP GeoMeta Meta e Recursos"
    462 
    463 #: lib/wp-geometa-dash.php:998
    464 #, php-format
    465 msgid ""
    466 "WP GeoMeta is a work of love from the GIS+WordPress development team at %1$s"
    467 msgstr ""
    468 "WP GeoMeta é um obra de amor to time de desenvolvimento de GIS+WordPress de "
    469 "%1$s."
    470 
    471 #: lib/wp-geometa-dash.php:1000
     461#: lib/wp-geometa-dash.php:1039
     462msgid "WP-GeoMeta Version"
     463msgstr ""
     464
     465#: lib/wp-geometa-dash.php:1058
     466msgid "WP-GeoMeta Meta and Resources"
     467msgstr ""
     468
     469#: lib/wp-geometa-dash.php:1061
     470#, php-format
     471msgid ""
     472"WP-GeoMeta is a work of love from the GIS+WordPress development team at %1$s"
     473msgstr ""
     474
     475#: lib/wp-geometa-dash.php:1063
    472476#, php-format
    473477msgid ""
     
    478482"requests (especialmente com casos teste)%4$s."
    479483
    480 #: lib/wp-geometa-dash.php:1002
     484#: lib/wp-geometa-dash.php:1065
    481485#, php-format
    482486msgid ""
     
    487491"contacta%2$s com detalhes sobre que você quer fazer."
    488492
    489 #: lib/wp-geometa-dash.php:1005
     493#: lib/wp-geometa-dash.php:1068
    490494msgid "Our Sites"
    491495msgstr "Nossos Sites"
    492496
    493 #: lib/wp-geometa-dash.php:1007
     497#: lib/wp-geometa-dash.php:1070
    494498msgid "Our home on the web"
    495499msgstr "Nossa lar no web"
    496500
    497 #: lib/wp-geometa-dash.php:1008
    498 msgid "WP GeoMeta on GitHub"
    499 msgstr "WP GeoMeta no GitHub"
    500 
    501 #: lib/wp-geometa-dash.php:1009
    502 msgid "WherePress.com — Our WordPress/GIS Blog Site"
    503 msgstr "WherePress.com — Nossa Blog de WordPress/SIG "
    504 
    505 #: lib/wp-geometa-dash.php:1012
     501#: lib/wp-geometa-dash.php:1071
     502msgid "WP-GeoMeta on GitHub"
     503msgstr ""
     504
     505#: lib/wp-geometa-dash.php:1075
    506506msgid "Documentation"
    507507msgstr "Documentação"
    508508
    509 #: lib/wp-geometa-dash.php:1014
     509#: lib/wp-geometa-dash.php:1077
    510510msgid "MySQL (5.7) Spatial Analysis Functions Documentation"
    511511msgstr "Documentação de Funções de Analise Espacial de MySQL (5.7)"
    512512
    513 #: lib/wp-geometa-dash.php:1015
     513#: lib/wp-geometa-dash.php:1078
    514514msgid "MariaDB Geographic Features Documentation"
    515515msgstr "Documentação de Objectos Geográficas MariaDB"
    516516
    517 #: lib/wp-geometa-dash.php:1016
     517#: lib/wp-geometa-dash.php:1079
    518518msgid "MySQL/MariaDB Spatial Support Matrix"
    519519msgstr "Matriz de Apoio Espacial MySQL/MariaDB"
    520520
    521 #: lib/wp-geometa-dash.php:1017
     521#: lib/wp-geometa-dash.php:1080
    522522#, php-format
    523523msgid "%1$sAdd%2$s, %3$sUpdate%4$s and %5$sDelete%6$s post meta"
    524524msgstr "%1$sAdicionar%2$s, %3$sAtualizar%4$s e %5$sDelete%6$s post meta"
    525525
    526 #: lib/wp-geometa-dash.php:1018
     526#: lib/wp-geometa-dash.php:1081
    527527#, php-format
    528528msgid "%1$sWP_Query%2$s and %3$sWP_Meta_Query%4$s"
    529529msgstr "%1$sWP_Query%2$s e %3$sWP_Meta_Query%4$s"
    530530
    531 #: lib/wp-geometa-dash.php:1019
     531#: lib/wp-geometa-dash.php:1082
    532532msgid "GeoJSON Specification"
    533533msgstr "Specificação GeoJSON"
    534534
    535 #: lib/wp-geometa-dash.php:1020
     535#: lib/wp-geometa-dash.php:1083
    536536msgid "Leaflet.js - Our recommended map software"
    537537msgstr "Leaflet.js - Nosso software de mapas recomendado"
    538538
    539 #: lib/wp-geometa-dash.php:1023
     539#: lib/wp-geometa-dash.php:1086
    540540msgid "GIS Communities"
    541541msgstr "Communidades SIG"
    542542
    543 #: lib/wp-geometa-dash.php:1025
     543#: lib/wp-geometa-dash.php:1088
    544544msgid "GIS StackExchange"
    545545msgstr "StackExchange SIG"
    546546
    547 #: lib/wp-geometa-dash.php:1035
     547#: lib/wp-geometa-dash.php:1098
    548548msgid "The Danger Zone"
    549549msgstr "Zona Perigosa"
    550550
    551 #: lib/wp-geometa-dash.php:1037
     551#: lib/wp-geometa-dash.php:1100
    552552#, php-format
    553553msgid ""
     
    561561"os existem."
    562562
    563 #: lib/wp-geometa-dash.php:1040
     563#: lib/wp-geometa-dash.php:1103
    564564msgid "Enter The Danger Zone"
    565565msgstr "Entre a Zona Perigosa"
    566566
    567 #: lib/wp-geometa-dash.php:1045
     567#: lib/wp-geometa-dash.php:1108
    568568msgid "Run Regression Tests"
    569569msgstr "Corre Provas de Regressão"
    570570
    571 #: lib/wp-geometa-dash.php:1046
    572 msgid "Run the built-in regression tests"
    573 msgstr "Corre as provas de regressão integral."
    574 
    575 #: lib/wp-geometa-dash.php:1049
    576 msgid "Remove WP GeoMeta Tables"
    577 msgstr "Remover Tabelas WP GeoMeta"
    578 
    579 #: lib/wp-geometa-dash.php:1050
    580 msgid ""
    581 "All WP GeoMeta data is stored in its own tables. Your original data is "
    582 "untouched. Removing WP GeoMeta tables will break any spatial queries you may "
     571#: lib/wp-geometa-dash.php:1109
     572msgid ""
     573"Run the built-in regression tests against the in-use vesion of WP-GeoMeta-Lib"
     574msgstr ""
     575
     576#: lib/wp-geometa-dash.php:1112
     577msgid "Remove WP-GeoMeta Tables"
     578msgstr ""
     579
     580#: lib/wp-geometa-dash.php:1113
     581msgid ""
     582"All WP-GeoMeta data is stored in its own tables. Your original data is "
     583"untouched. Removing WP-GeoMeta tables will break any spatial queries you may "
    583584"be using."
    584585msgstr ""
    585 "Todos os dados de WP GeoMeta estão salvados em seus próprios tabelas. Seus "
    586 "dados originais não é modificados. Apagando as tabelas WP GeoMeta vai "
    587 "quebrar qualquer pesquisas espaciais você pode estar usando."
    588 
    589 #: lib/wp-geometa-dash.php:1053
    590 msgid "Create WP GeoMeta Tables"
    591 msgstr "Criar Tabelas WP GeoMeta"
    592 
    593 #: lib/wp-geometa-dash.php:1054
    594 msgid ""
    595 "WP GeoMeta tables are created on plugin activation or upgrade, but you can "
    596 "manually create them here. WP GeoMeta uses dbDelta, so running this multiple "
     586
     587#: lib/wp-geometa-dash.php:1116
     588msgid "Create WP-GeoMeta Tables and Functions"
     589msgstr ""
     590
     591#: lib/wp-geometa-dash.php:1117
     592msgid ""
     593"WP-GeoMeta tables are created on plugin activation or upgrade, but you can "
     594"manually create them here. WP-GeoMeta uses dbDelta, so running this multiple "
    597595"times will have no bad effects."
    598596msgstr ""
    599 "Tabelas WP GeoMeta estão criados quando o plugin esta activado ou "
    600 "atualizado, mas você pode as criar aqui manualmente. WP GeoMeta usa dbDelta, "
    601 "então fazendo isso vários vezes não teria efeitos maus."
    602 
    603 #: lib/wp-geometa-dash.php:1057
    604 msgid "Truncate WP GeoMeta Tables"
    605 msgstr "Truncar Tabelas WP GeoMeta"
    606 
    607 #: lib/wp-geometa-dash.php:1058
     597
     598#: lib/wp-geometa-dash.php:1120
     599msgid "Truncate WP-GeoMeta Tables"
     600msgstr ""
     601
     602#: lib/wp-geometa-dash.php:1121
    608603msgid "Clears existing spatial data, but doesn't remove the tables."
    609604msgstr "Apagar dados espaciais atuais, mas não apagar as tabelas."
    610605
    611 #: lib/wp-geometa-dash.php:1062
     606#: lib/wp-geometa-dash.php:1125
    612607msgid ""
    613608"Detect any spatial data (GeoJSON) in the non-spatial meta tables which is "
    614 "not stored in WP GeoMeta and load it. This may take a while!"
    615 msgstr ""
    616 "Detectar dados espaciais (GeoJSON) nas tabelas meta não-espaciais que não "
    617 "esta salvado em WP GeoMeta, e carregá-lo. Este ação pode demorar!"
     609"not stored in WP-GeoMeta and load it. This may take a while!"
     610msgstr ""
     611
     612#: lib/wp-geometa-dash.php:1128
     613msgid "Rebuild spatial function cache"
     614msgstr ""
     615
     616#: lib/wp-geometa-dash.php:1129
     617msgid "Re-check and cache which MySQL spatial functions are supported."
     618msgstr ""
     619
     620#~ msgid "You are running the most recent version of WP GeoMeta (%1$s)."
     621#~ msgstr "Você esta usando o versão mais recente de WP GeoMeta (%1$s)."
     622
     623#~ msgid ""
     624#~ "A plugin you are using is providing the most recent version of the WP "
     625#~ "GeoMeta library (%1$s), but this plugin is out of date."
     626#~ msgstr ""
     627#~ "Um plugin você esta usando esta providenciando o versão mais recente do "
     628#~ "módulo WP GeoMeta (%1$s), mas este plugin esta desactualizado."
     629
     630#~ msgid ""
     631#~ "You are running an outdated version of WP GeoMeta (%1$s). Please upgrade!"
     632#~ msgstr ""
     633#~ "Você esta usando um versão desatualizado de WP GeoMeta (%1$s). Atualiza "
     634#~ "porfavor!"
     635
     636#~ msgid "Populate WP GeoMeta Tables"
     637#~ msgstr "Popular as tabelas WP GeoMeta"
     638
     639#~ msgid "The WP GeoMeta tables should be gone now."
     640#~ msgstr "As tabelas WP GeoMeta devem ser ido agora."
     641
     642#~ msgid "The WP GeoMeta tables should exist now."
     643#~ msgstr "As tabelas WP GeoMeta devem existir agora."
     644
     645#~ msgid "The WP GeoMeta tables should be empty now."
     646#~ msgstr "As tabelas WP GeoMeta devem estar vazios agora."
     647
     648#~ msgid "The WP GeoMeta tables should be populated now."
     649#~ msgstr "As tabelas WP GeoMeta devem estar preenchido agora."
     650
     651#~ msgid ""
     652#~ "WP GeoMeta uses the standard WordPress metadata functions. If you are "
     653#~ "familiar with these functions, you already know how to use WP GeoMeta."
     654#~ msgstr ""
     655#~ "WP GeoMeta usa os funções WordPress metadata padrão. Se você já tem "
     656#~ "familiaridade com estes funções, você ja sabe como usar o WP GeoMeta."
     657
     658#~ msgid ""
     659#~ "WP GeoMeta watches for GeoJSON metadata values being saved to the "
     660#~ "database. It saves the GeoJSON like WordPress expects, but also converts "
     661#~ "the GeoJSON into a spatial format MySQL understands and saves that to "
     662#~ "special geo-meta tables which can handle spatial data and which have "
     663#~ "spatial indexes."
     664#~ msgstr ""
     665#~ "WP GeoMeta fica de olho para valores metadados tipo GeoJSON sendo "
     666#~ "guardados no banco de dados. O escreve o GeoJSON como WordPress espera, "
     667#~ "mas também converta o GeoJSON em um formato espaciais que MySQL "
     668#~ "compreende, e guarda aquele em tabelas especiais de geo-meta que podem "
     669#~ "utilizar dados espaciais e que tem índices espaciais."
     670
     671#~ msgid ""
     672#~ "WP GeoMeta doesn't do anything when fetching data. You will get back the "
     673#~ "same GeoJSON value that you stored previously."
     674#~ msgstr ""
     675#~ "WP GeoMeta não faz nada quando buscando dados. Você receberá o mesmo "
     676#~ "valor de GeoJSON que você adicionou anteriormente."
     677
     678#~ msgid ""
     679#~ "The real power of GIS and Spatial data becomes evident when you start "
     680#~ "doing real spatial searches. WP GeoMeta integrates with WP_Query, "
     681#~ "get_posts and other functions that use WP_Meta_Query under the hood."
     682#~ msgstr ""
     683#~ "O verdadero pode de SIG e dados espaciais se tornam evidente quando você "
     684#~ "começa a fazer buscas espaciais reais. WP GeoMeta integra com WP_Query, "
     685#~ "get_posts e outros funções que usam WP_Meta_Query sob o capô."
     686
     687#~ msgid ""
     688#~ "WP GeoMeta can be installed as a plugin or used as a library by other "
     689#~ "plugins. This list includes all installed versions of WP GeoMeta and "
     690#~ "which plugin they came with."
     691#~ msgstr ""
     692#~ "WP GeoMeta pode ser instalado como um plugin ou utilizado como um "
     693#~ "biblioteca por outros plugins. Este lista inclui todos os versões de WP "
     694#~ "GeoMeta installados e com qual plugin eles foram incluídos."
     695
     696#~ msgid ""
     697#~ "WP GeoMeta always uses the most up to date version installed, even if a "
     698#~ "plugin bundles an older version."
     699#~ msgstr ""
     700#~ "WP GeoMeta sempre usa o versão mais recente instalado, mesmo se um plugin "
     701#~ "inclue um versão mais velho."
     702
     703#~ msgid "WP GeoMeta Version"
     704#~ msgstr "Versão de WP GeoMeta"
     705
     706#~ msgid "WP GeoMeta Meta and Resources"
     707#~ msgstr "WP GeoMeta Meta e Recursos"
     708
     709#~ msgid ""
     710#~ "WP GeoMeta is a work of love from the GIS+WordPress development team at "
     711#~ "%1$s"
     712#~ msgstr ""
     713#~ "WP GeoMeta é um obra de amor to time de desenvolvimento de GIS+WordPress "
     714#~ "de %1$s."
     715
     716#~ msgid "WP GeoMeta on GitHub"
     717#~ msgstr "WP GeoMeta no GitHub"
     718
     719#~ msgid "WherePress.com — Our WordPress/GIS Blog Site"
     720#~ msgstr "WherePress.com — Nossa Blog de WordPress/SIG "
     721
     722#~ msgid "Run the built-in regression tests"
     723#~ msgstr "Corre as provas de regressão integral."
     724
     725#~ msgid "Remove WP GeoMeta Tables"
     726#~ msgstr "Remover Tabelas WP GeoMeta"
     727
     728#~ msgid ""
     729#~ "All WP GeoMeta data is stored in its own tables. Your original data is "
     730#~ "untouched. Removing WP GeoMeta tables will break any spatial queries you "
     731#~ "may be using."
     732#~ msgstr ""
     733#~ "Todos os dados de WP GeoMeta estão salvados em seus próprios tabelas. "
     734#~ "Seus dados originais não é modificados. Apagando as tabelas WP GeoMeta "
     735#~ "vai quebrar qualquer pesquisas espaciais você pode estar usando."
     736
     737#~ msgid "Create WP GeoMeta Tables"
     738#~ msgstr "Criar Tabelas WP GeoMeta"
     739
     740#~ msgid ""
     741#~ "WP GeoMeta tables are created on plugin activation or upgrade, but you "
     742#~ "can manually create them here. WP GeoMeta uses dbDelta, so running this "
     743#~ "multiple times will have no bad effects."
     744#~ msgstr ""
     745#~ "Tabelas WP GeoMeta estão criados quando o plugin esta activado ou "
     746#~ "atualizado, mas você pode as criar aqui manualmente. WP GeoMeta usa "
     747#~ "dbDelta, então fazendo isso vários vezes não teria efeitos maus."
     748
     749#~ msgid "Truncate WP GeoMeta Tables"
     750#~ msgstr "Truncar Tabelas WP GeoMeta"
     751
     752#~ msgid ""
     753#~ "Detect any spatial data (GeoJSON) in the non-spatial meta tables which is "
     754#~ "not stored in WP GeoMeta and load it. This may take a while!"
     755#~ msgstr ""
     756#~ "Detectar dados espaciais (GeoJSON) nas tabelas meta não-espaciais que não "
     757#~ "esta salvado em WP GeoMeta, e carregá-lo. Este ação pode demorar!"
    618758
    619759#~ msgid ""
  • wp-geometa/trunk/lib/wp-geometa-dash.php

    r1557784 r1607853  
    11<?php
    22/**
    3  * This class and file are respnsible for the WP GeoMeta WordPress dashboard page. This file doesn't need to be loaded
    4  * when WP GeoMeta is used as a library.
     3 * This class and file are respnsible for the WP-GeoMeta WordPress dashboard page.
    54 *
    65 * @package wp-geometa
    76 * @link https://github.com/cimburadotcom/WP-GeoMeta
    8  * @author Michael Moore / michael_m@cimbura.com / https://profiles.wordpress.org/stuporglue/
    9  * @copyright Cimbura.com, 2016
     7 * @author Michael Moore / michael.moore@luminfire.com / https://profiles.wordpress.org/stuporglue/
     8 * @copyright LuminFire.com, 2016, 2017
    109 * @license GNU GPL v2
    1110 */
     
    292291    protected function __construct() {
    293292        add_action( 'admin_menu', array( $this, 'admin_menu' ) );
    294         add_action( 'wp_ajax_wpgm_get_sample_data', array( $this, 'ajax_wpgm_get_sample_data' ) );
    295         add_action( 'wp_ajax_wpgm_dangerzone', array( $this, 'ajax_wpgm_dangerzone' ) );
     293        add_action( 'wp_ajax_wpgm_get_sample_data', array( $this, 'wp_ajax_wpgm_get_sample_data' ) );
     294        add_action( 'wp_ajax_wpgm_dangerzone', array( $this, 'wp_ajax_wpgm_dangerzone' ) );
    296295        add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
    297         add_filter( 'wpgmd_sample_data_to_json', array( $this, 'sample_latlng_to_json' ) );
     296        add_filter( 'wpgmd_sample_data_to_json', array( $this, 'wpgmd_sample_data_to_json' ), 10, 2 );
    298297    }
    299298
     
    308307        }
    309308
    310         $plugin_dir = plugin_dir_url( __FILE__ ) . '/../../assets/';
     309        $plugin_dir = plugin_dir_url( __FILE__ ) . '/../../media/';
    311310
    312311        wp_enqueue_script( 'leafletjs', $plugin_dir . 'leaflet/leaflet.js', array(), null );
     
    317316        $translation_array = array(
    318317            'action_confirm_dialog' => __( 'Are you sure you want to %1$s?' , 'wp-geometa' ),
    319             );
     318        );
    320319        wp_localize_script( 'wpgeometadashjs', 'wpgmjs_strings', $translation_array );
    321320        wp_enqueue_script( 'wpgeometadashjs' );
     
    329328     */
    330329    public function admin_menu() {
    331         add_management_page( 'WP GeoMeta', 'WP GeoMeta', 'install_plugins', 'wp-geometa', array( $this, 'show_dashboard' ) );
     330        add_management_page( 'WP-GeoMeta', 'WP-GeoMeta', 'install_plugins', 'wp-geometa', array( $this, 'show_dashboard' ) );
    332331    }
    333332
     
    470469
    471470        $all_plugins = get_plugin_updates();
    472 
    473471        $this_plugin = basename( dirname( dirname( __FILE__ ) ) ) . '/wp-geometa.php';
     472        $plugin_data = get_plugin_data( dirname( dirname( __FILE__ ) )  . '/wp-geometa.php' );
     473        $geometa_dash_version = $plugin_data['Version'];
     474
     475        $latest_version = WP_GEOMETA_VERSION;
     476
     477        if ( !empty( $all_plugins[ $this_plugin ] ) && !empty( $all_plugins[ $this_plugin ]->update->new_version ) ) {
     478            $update_version = $all_plugins[ $this_plugin ]->update->new_version;
     479
     480            if ( 0 >= version_compare( $latest_version, $update_version ) ) {
     481                $latest_version = $update_version;
     482            }
     483        }
    474484
    475485        /*
    476486         * Three statuses.
    477          * Poor. There are updates and WP_GEOMETA_DASH_VERSION and WP_GEOMETA_VERSION are the same and both are out of date
    478          * OK. There are updates, and WP_GEOMETA_DASH_VERSION is out of date, but WP_GEOMETA_VERSION is up to date (some other plugin has an updated version)
    479          * Good. There are no updates: WP_GEOMETA_DASH_VERSION is up to date and WP_GEOMETA_VERSION is up to date
     487         * Poor. There are updates and $geometa_dash_version and WP_GEOMETA_VERSION are the same and both are out of date
     488         * OK. There are updates, and $geometa_dash_version is out of date, but WP_GEOMETA_VERSION is up to date (some other plugin has an updated version)
     489         * Good. There are no updates: $geometa_dash_version is up to date and WP_GEOMETA_VERSION is up to date
    480490         */
    481491
    482         if ( empty( $all_plugins[ $this_plugin ] ) ) {
    483             $this->make_status_block( 'good', esc_html__( 'Up To Date!' , 'wp-geometa' ), sprintf( esc_html__( 'You are running the most recent version of WP GeoMeta (%1$s).', 'wp-geometa' ), WP_GEOMETA_VERSION ) );
    484         } else if ( 0 === version_compare( WP_GEOMETA_VERSION, $all_plugins[ $this_plugin ]->Version ) && -1 === version_compare( WP_GEOMETA_DASH_VERSION, $all_plugins[ $this_plugin ]->Version ) ) {
    485             $this->make_status_block( 'fair', esc_html__( 'Out Of Date.' , 'wp-geometa' ), sprintf( esc_html__( 'A plugin you are using is providing the most recent version of the WP GeoMeta library (%1$s), but this plugin is out of date.', 'wp-geometa' ), WP_GEOMETA_VERSION ) );
    486         } else {
    487             $this->make_status_block( 'poor', esc_html__( 'Out Of Date!' , 'wp-geometa' ), sprintf( esc_html__( 'You are running an outdated version of WP GeoMeta (%1$s). Please upgrade!', 'wp-geometa' ), WP_GEOMETA_VERSION ) );
     492
     493        // Poor. We have the latest, but it's not in use. This is unexpected.
     494        if ( -1 === version_compare( WP_GEOMETA_VERSION, $geometa_dash_version ) ) {
     495            $this->make_status_block( 'poor', esc_html__( 'Odd Situation!' , 'wp-geometa' ), sprintf( esc_html__( 'You have the latest version of WP-GeoMeta, but another plugin is providing an older version WP-GeoMeta-Lib Please update the plugin(s) not providing version %1$s in the list below!', 'wp-geometa' ), $latest_version ) );
     496        }
     497
     498        // Good: We've got the latest.
     499        else if ( 0 >= version_compare( $latest_version, $geometa_dash_version ) ) {
     500            $this->make_status_block( 'good', esc_html__( 'Up To Date!' , 'wp-geometa' ), sprintf( esc_html__( 'You are using the most recent version of WP-GeoMeta-Lib (%1$s).', 'wp-geometa' ), WP_GEOMETA_VERSION ) );
     501        }
     502
     503
     504        // OK. Some other plugin is providing the latest version.
     505        else if (  1 === version_compare( $latest_version, $geometa_dash_version ) && 0 === version_compare( WP_GEOMETA_VERSION, $latest_version ) ) {
     506            $this->make_status_block( 'fair', esc_html__( 'Out Of Date.' , 'wp-geometa' ), sprintf( esc_html__( 'A plugin you are using is providing the most recent version of the WP-GeoMeta-Lib (%1$s), but this plugin is out of date.', 'wp-geometa' ), WP_GEOMETA_VERSION ) );
     507        }
     508       
     509        // Poor: There are updates and no plugin has them.
     510        else {
     511            $this->make_status_block( 'poor', esc_html__( 'Out Of Date!' , 'wp-geometa' ), sprintf( esc_html__( 'You are running an outdated version of WP-GeoMeta-Lib (%1$s). Please upgrade to %2$s!', 'wp-geometa' ), WP_GEOMETA_VERSION, $latest_version ) );
    488512        }
    489513    }
     
    540564            $this->make_status_block( 'good', esc_html__( 'All Spatial Data Loaded!' , 'wp-geometa' ), sprintf( esc_html__( 'All %1$s spatial records are loaded!' , 'wp-geometa' ), $total_meta ) );
    541565        } else if ( $total_percent > 0 ) {
    542             $this->make_status_block( 'fair', esc_html__( 'Some Spatial Data Loaded' , 'wp-geometa' ), sprintf( esc_html__( '%1$s%% of spatial records are loaded (%2$s records not loaded). Try using the %3$s%4$s%5$s tool below to load them.', 'wp-geometa' ), $total_percent, ( $total_meta - $total_geo ), '<em>', esc_html__( 'Populate WP GeoMeta Tables', 'wp-geometa' ), '</em>' ) );
     566            $this->make_status_block( 'fair', esc_html__( 'Some Spatial Data Loaded' , 'wp-geometa' ), sprintf( esc_html__( '%1$s%% of spatial records are loaded (%2$s records not loaded). Try using the %3$s%4$s%5$s tool below to load them.', 'wp-geometa' ), $total_percent, ( $total_meta - $total_geo ), '<em>', esc_html__( 'Populate WP-GeoMeta Tables', 'wp-geometa' ), '</em>' ) );
    543567        } else {
    544             $this->make_status_block( 'poor', esc_html__( 'No Spatial Data Loaded!' , 'wp-geometa' ), sprintf( esc_html__( 'Please verify that the spatial tables exist, then use the %1$s%2$s%3$s tool below to load the data.' , 'wp-geometa' ), '<em>', esc_html__( 'Populate WP GeoMeta Tables' ), '</em>' ) );
     568            $this->make_status_block( 'poor', esc_html__( 'No Spatial Data Loaded!' , 'wp-geometa' ), sprintf( esc_html__( 'Please verify that the spatial tables exist, then use the %1$s%2$s%3$s tool below to load the data.' , 'wp-geometa' ), '<em>', esc_html__( 'Populate WP-GeoMeta Tables' ), '</em>' ) );
    545569        }
    546570    }
     
    584608                ORDER BY p.post_type, geo.meta_key';
    585609
    586         foreach ( $wpdb->get_results( $q, ARRAY_A ) as $geometa ) {  // @codingStandardsIgnoreLine
    587 
    588                 $post_type_object = get_post_type_object( $geometa['post_type'] );
    589 
    590                 $found_data[] = array(
    591                     'name' => $post_type_object->labels->name . ' (post)',
    592                     'type' => 'post',
    593                     'the_meta_key' => $geometa['meta_key'],
    594                     'quantity' => $geometa['quantity'],
    595                     'sub_type' => $geometa['post_type'],
    596                             );
    597             }
     610foreach ( $wpdb->get_results( $q, ARRAY_A ) as $geometa ) {  // @codingStandardsIgnoreLine
     611
     612    $post_type_object = get_post_type_object( $geometa['post_type'] );
     613
     614    $found_data[] = array(
     615        'name' => $post_type_object->labels->name . ' (post)',
     616        'type' => 'post',
     617        'the_meta_key' => $geometa['meta_key'],
     618        'quantity' => $geometa['quantity'],
     619        'sub_type' => $geometa['post_type'],
     620    );
     621}
    598622        }
    599623
     
    607631             */
    608632            // @codingStandardsIgnoreStart
    609             $q = 'SELECT
    610                 meta_key,
    611                 COUNT(umeta_id) AS quantity
    612                 FROM
    613                 ' . $wpdb->usermeta . '_geo geo
    614                 GROUP BY
    615                 meta_key';
    616 
    617 // @codingStandardsIgnoreEnd
    618 
    619 foreach ( $wpdb->get_results( $q, ARRAY_A ) as $usermeta ) {  // @codingStandardsIgnoreLine
     633            $q = 'SELECT meta_key, COUNT(umeta_id) AS quantity FROM ' . $wpdb->usermeta . '_geo geo GROUP BY meta_key';
     634            // @codingStandardsIgnoreEnd
     635
     636            foreach ( $wpdb->get_results( $q, ARRAY_A ) as $usermeta ) {  // @codingStandardsIgnoreLine
    620637                $found_data[] = array(
    621638                    'name' => 'Users',
     
    623640                    'the_meta_key' => $usermeta['meta_key'],
    624641                    'quantity' => $usermeta['quantity'],
    625                             );
     642                );
    626643            }
    627644        }
     
    646663foreach ( $wpdb->get_results( $q, ARRAY_A ) as $termmeta ) { // @codingStandardsIgnoreLine
    647664
    648                 $found_data[] = array(
    649                     'name' => $termmeta['name'] . ' (term)',
    650                     'type' => 'user',
    651                     'the_meta_key' => $termmeta['meta_key'],
    652                     'quantity' => $termmeta['quantity'],
    653                             );
    654             }
     665    $found_data[] = array(
     666        'name' => $termmeta['name'] . ' (term)',
     667        'type' => 'user',
     668        'the_meta_key' => $termmeta['meta_key'],
     669        'quantity' => $termmeta['quantity'],
     670    );
     671}
    655672        }
    656673
     
    666683
    667684foreach ( $wpdb->get_results( $q, ARRAY_A ) as $commentmeta ) { // @codingStandardsIgnoreLine
    668                 $found_data[] = array(
    669                     'name' => 'Comments',
    670                     'type' => 'comment',
    671                     'the_meta_key' => $commentmeta['meta_key'],
    672                     'quantity' => $commentmeta['quantity'],
    673                             );
    674             }
     685    $found_data[] = array(
     686        'name' => 'Comments',
     687        'type' => 'comment',
     688        'the_meta_key' => $commentmeta['meta_key'],
     689        'quantity' => $commentmeta['quantity'],
     690    );
     691}
    675692        }
    676693
     
    685702     * Get 500 random spatial records from a post type.
    686703     */
    687     public function ajax_wpgm_get_sample_data() {
     704    public function wp_ajax_wpgm_get_sample_data() {
    688705        global $wpdb;
    689706
     
    748765        if ( ! empty( $_GET['subtype'] ) ) { // @codingStandardsIgnoreLine
    749766            $post_type_object = get_post_type_object( $_GET['subtype'] );  // @codingStandardsIgnoreLine
    750             $type = $post_type_object->labels->name . ' (post)';
     767            $type_label = $post_type_object->labels->name . ' (post)';
    751768        } else {
    752             $type = ucfirst( $type );
     769            $type_label = ucfirst( $type );
    753770        }
    754771
    755772        foreach ( $res as $record ) {
    756773
    757             $record = apply_filters( 'wpgmd_sample_data_to_json', $record );
     774            $record = apply_filters( 'wpgmd_sample_data_to_json', $record, $type );
    758775
    759776            $feature_collection = WP_GeoUtil::merge_geojson( $record['meta_value'] );
    760777            $feature_collection = json_decode( $feature_collection, true );
    761778            foreach ( $feature_collection['features'] as &$feature ) {
    762                 $feature['title'] = $type . ' id ' . $record['the_id'];
     779                $feature['title'] = $type_label . ' id ' . $record['the_id'];
    763780            }
    764781            $geojson[] = $feature_collection;
     
    777794
    778795    /**
    779      * Generate a list of WP GeoMeta installs.
     796     * Generate a list of WP-GeoMeta installs.
    780797     */
    781798    function get_list_of_installs() {
     
    812829     * Handle the danger zone actions
    813830     */
    814     public function ajax_wpgm_dangerzone() {
     831    public function wp_ajax_wpgm_dangerzone() {
    815832        $real_action = $_GET['action_type']; // @codingStandardsIgnoreLine
    816833
     
    818835            case 'run-tests':
    819836                ob_start();
    820                 require_once( dirname( __FILE__ ) . '/../test/testsuite.php' );
     837                require_once( dirname( __FILE__ ) . '/wp-geometa-lib/test/testsuite.php' );
    821838                $res = ob_get_clean();
    822839                $res = trim( $res );
     
    828845                $wpgm = WP_GeoMeta::get_instance();
    829846                $wpgm->uninstall();
    830                 print esc_html__( 'The WP GeoMeta tables should be gone now.' , 'wp-geometa' );
     847                print esc_html__( 'The WP-GeoMeta tables should be gone now.' , 'wp-geometa' );
    831848                break;
    832849            case 'create-tables':
    833850                $wpgm = WP_GeoMeta::get_instance();
    834851                $wpgm->create_geo_tables();
    835                 print esc_html__( 'The WP GeoMeta tables should exist now.' , 'wp-geometa' );
     852                print esc_html__( 'The WP-GeoMeta tables and functions should exist now.' , 'wp-geometa' );
    836853                break;
    837854            case 'truncate-tables':
    838855                $wpgm = WP_GeoMeta::get_instance();
    839856                $wpgm->truncate_tables();
    840                 print esc_html__( 'The WP GeoMeta tables should be empty now.' , 'wp-geometa' );
     857                print esc_html__( 'The WP-GeoMeta tables should be empty now.' , 'wp-geometa' );
    841858                break;
    842859                break;
     
    844861                $wpgm = WP_GeoMeta::get_instance();
    845862                $wpgm->populate_geo_tables();
    846                 print esc_html__( 'The WP GeoMeta tables should be populated now.' , 'wp-geometa' );
     863                print esc_html__( 'The WP-GeoMeta tables should be populated now.' , 'wp-geometa' );
    847864                break;
    848865            case 'rebuild-function-cache':
     
    861878     */
    862879    public function section_header() {
    863         $icon = plugin_dir_url( __FILE__ ) . '/../../assets/icon.png';
    864         print '<div class="wpgm-header header noborder"><h2><img src="' . esc_attr( $icon ). '" title="WP GeoMeta Logo"/>WP GeoMeta</h2></div>';
     880        $icon = plugin_dir_url( __FILE__ ) . '/../../assets/icon-256x256.png';
     881        print '<div class="wpgm-header header noborder"><h2><img src="' . esc_attr( $icon ). '" title="WP-GeoMeta Logo"/>WP-GeoMeta</h2></div>';
    865882    }
    866883
     
    884901     */
    885902    public function section_data() {
    886         print '<div class="wpgm-data"><h3>' . esc_html__( 'Your Spatial Data' , 'wp-geometa' ) . '<span id="yourdata-spinner"></span></h3><div id="wpgmmap"></div><div class="posttypegeotable">';
     903        print '<div class="wpgm-data"><h3>' . esc_html__( 'Your Spatial Data' , 'wp-geometa' ) . '<span id="yourdata-spinner"></span></h3>';
     904
     905        $map = new LeafletPHP(array(
     906            'scrollWheelZoom' => false
     907            ),'wpgmleaflet');
     908
     909        print $map;
     910
     911        print '<div class="posttypegeotable">';
    887912        print '<h4>' . esc_html__( 'Found Spatial Metadata Types' , 'wp-geometa' ) . '</h4>';
    888913
     
    921946        print '<div><h3>' . esc_html__( 'Quick Start' , 'wp-geometa' ) .'</h3>';
    922947
    923         print '<p>' . esc_html__( 'WP GeoMeta uses the standard WordPress metadata functions. If you are familiar with these functions, you already know how to use WP GeoMeta.' , 'wp-geometa' ) . '</p>';
    924 
    925         print '<p>' . esc_html__( 'WP GeoMeta watches for GeoJSON metadata values being saved to the database. It saves the GeoJSON like WordPress expects, but also converts the GeoJSON into a spatial format MySQL understands and saves that to special geo-meta tables which can handle spatial data and which have spatial indexes.' , 'wp-geometa' ) . '</p>';
     948        print '<p>' . esc_html__( 'WP-GeoMeta uses the standard WordPress metadata functions. If you are familiar with these functions, you already know how to use WP-GeoMeta.' , 'wp-geometa' ) . '</p>';
     949
     950        print '<p>' . esc_html__( 'WP-GeoMeta watches for GeoJSON metadata values being saved to the database. It saves the GeoJSON like WordPress expects, but also converts the GeoJSON into a spatial format MySQL understands and saves that to special geo-meta tables which can handle spatial data and which have spatial indexes.' , 'wp-geometa' ) . '</p>';
    926951
    927952        print '<h4>' . esc_html__( 'Adding and Updating Data' , 'wp-geometa' ) . '</h4>';
     
    941966        print '<h4>' . esc_html__( 'Fetching and Using Data' , 'wp-geometa' ) . '</h4>';
    942967
    943         print '<p>' . esc_html__( 'WP GeoMeta doesn\'t do anything when fetching data. You will get back the same GeoJSON value that you stored previously.' , 'wp-geometa' ) . '</p>';
     968        print '<p>' . esc_html__( 'WP-GeoMeta doesn\'t do anything when fetching data. You will get back the same GeoJSON value that you stored previously.' , 'wp-geometa' ) . '</p>';
    944969        print '<p>' . esc_html__( 'GeoJSON can be used by any of the popular web map software available today.' , 'wp-geometa' ) . '</p>';
    945970        print '<pre><code>';
     
    952977        print '<h4>' . esc_html__( 'Running Spatial Queries' , 'wp-geometa' ) . '</h4>';
    953978
    954         print '<p>' . esc_html__( 'The real power of GIS and Spatial data becomes evident when you start doing real spatial searches. WP GeoMeta integrates with WP_Query, get_posts and other functions that use WP_Meta_Query under the hood.' , 'wp-geometa' ) . '</p>';
     979        print '<p>' . esc_html__( 'The real power of GIS and Spatial data becomes evident when you start doing real spatial searches. WP-GeoMeta integrates with WP_Query, get_posts and other functions that use WP_Meta_Query under the hood.' , 'wp-geometa' ) . '</p>';
    955980
    956981        print '<pre><code>';
     
    10051030
    10061031    /**
    1007      * Print the list of WP GeoMeta installs.
     1032     * Print the list of WP-GeoMeta installs.
    10081033     */
    10091034    public function section_installs() {
    10101035        print '<div class="listofinstalls"><h3>' . esc_html__( 'List of Installs' , 'wp-geometa' ) . '</h3>';
    1011         print '<p>' . esc_html__( 'WP GeoMeta can be installed as a plugin or used as a library by other plugins. This list includes all installed versions of WP GeoMeta and which plugin they came with.' ) . '</p>';
    1012         print '<p>' . esc_html__( 'WP GeoMeta always uses the most up to date version installed, even if a plugin bundles an older version.' , 'wp-geometa' ) . '</p>';
    1013 
    1014         print '<table class="wpgminstalllist"><tr><th>' . esc_html__( 'Plugin Name' , 'wp-geometa' ) . '</th><th>' . esc_html__( 'WP GeoMeta Version' , 'wp-geometa' ) . '</th></tr>';
     1036        print '<p>' . esc_html__( 'The WP-GeoMeta-Lib library may be used by multiple plugins. This list includes all installed versions of WP-GeoMeta-Lib and which plugin they came with.' ) . '</p>';
     1037        print '<p>' . esc_html__( 'WP-GeoMeta always uses the most up to date version installed, even if a plugin bundles an older version.' , 'wp-geometa' ) . '</p>';
     1038
     1039        print '<table class="wpgminstalllist"><tr><th>' . esc_html__( 'Plugin Name' , 'wp-geometa' ) . '</th><th>' . esc_html__( 'WP-GeoMeta Version' , 'wp-geometa' ) . '</th></tr>';
    10151040
    10161041        $installs = $this->get_list_of_installs();
     
    10311056     */
    10321057    public function section_resources() {
    1033         print '<div><h3>' . esc_html__( 'WP GeoMeta Meta and Resources' , 'wp-geometa' ) . '</h3>';
    1034 
    1035         $logo = plugin_dir_url( __FILE__ ) . '/../../assets/cimbura_logo.png';
    1036         print '<p><img src="' . esc_attr( $logo ) . '" class="logo">' . sprintf( esc_html__( 'WP GeoMeta is a work of love from the GIS+WordPress development team at %1$s' , 'wp-geometa' ), '<a href="http://cimbura.com" target="_blank">Cimbura.com</a>' );
     1058        print '<div><h3>' . esc_html__( 'WP-GeoMeta Meta and Resources' , 'wp-geometa' ) . '</h3>';
     1059
     1060        $logo = plugin_dir_url( __FILE__ ) . '/../../media/luminfire_logo.png';
     1061        print '<p><img src="' . esc_attr( $logo ) . '" class="logo">' . sprintf( esc_html__( 'WP-GeoMeta is a work of love from the GIS+WordPress development team at %1$s' , 'wp-geometa' ), '<a href="https://luminfire.com" target="_blank">LuminFire.com</a>' );
    10371062        print ' ';
    10381063        printf( esc_html__( 'We appreciate %1$sbug reports, feature requests%2$s and %3$spull requests (especially with test cases)%4$s.', 'wp-geometa' ), '<a href="https://github.com/cimburadotcom/WP-GeoMeta/issues" target="_blank">', '</a>','<a href="https://github.com/cimburadotcom/WP-GeoMeta/pulls" target="_blank">', '</a>' );
     
    10431068        print '<h4>' . esc_html__( 'Our Sites' , 'wp-geometa' ) . '</h4>';
    10441069        print '<ul>';
    1045         print '<li><a href="https://cimbura.com" target="_blank">Cimbura.com — ' . esc_html__( 'Our home on the web' , 'wp-geometa' ) . '</a></li>';
    1046         print '<li><a href="https://github.com/cimburadotcom/WP-GeoMeta" target="_blank">' . esc_html__( 'WP GeoMeta on GitHub' , 'wp-geometa' ) . '</a></li>';
    1047         print '<li><a href="http://wherepress.com/" target="_blank">' . esc_html__( 'WherePress.com — Our WordPress/GIS Blog Site' , 'wp-geometa' ) . '</a></li>';
     1070        print '<li><a href="https://luminfire.com" target="_blank">LuminFire.com — ' . esc_html__( 'Our home on the web' , 'wp-geometa' ) . '</a></li>';
     1071        print '<li><a href="https://github.com/cimburadotcom/WP-GeoMeta" target="_blank">' . esc_html__( 'WP-GeoMeta on GitHub' , 'wp-geometa' ) . '</a></li>';
     1072        // print '<li><a href="http://wherepress.com/" target="_blank">' . esc_html__( 'WherePress.com — Our WordPress/GIS Blog Site' , 'wp-geometa' ) . '</a></li>';
    10481073        print '</ul>';
    10491074
     
    10821107        // Run tests.
    10831108        print '<tr><td><button data-action="run-tests" class="wpgm-danger-action">' . esc_html__( 'Run Regression Tests' , 'wp-geometa' ) . '</button></td>';
    1084         print '<td>' . esc_html__( 'Run the built-in regression tests' , 'wp-geometa' ) . '</td></tr>';
    1085 
    1086         // Remove WP GeoMeta Tables.
    1087         print '<tr><td><button data-action="remove-tables" class="wpgm-danger-action">' . esc_html__( 'Remove WP GeoMeta Tables' , 'wp-geometa' ) . '</button></td>';
    1088         print '<td>' . esc_html__( 'All WP GeoMeta data is stored in its own tables. Your original data is untouched. Removing WP GeoMeta tables will break any spatial queries you may be using.' , 'wp-geometa' ) . '</td></tr>';
    1089 
    1090         // Create WP GeoMeta Tables.
    1091         print '<tr><td><button data-action="create-tables" class="wpgm-danger-action">' . esc_html__( 'Create WP GeoMeta Tables' , 'wp-geometa' ) . '</button></td>';
    1092         print '<td>' . esc_html__( 'WP GeoMeta tables are created on plugin activation or upgrade, but you can manually create them here. WP GeoMeta uses dbDelta, so running this multiple times will have no bad effects.' , 'wp-geometa' ) . '</td></tr>';
    1093 
    1094         // Truncate WP GeoMeta Tables.
    1095         print '<tr><td><button data-action="truncate-tables" class="wpgm-danger-action">' . esc_html__( 'Truncate WP GeoMeta Tables' , 'wp-geometa' ) . '</button></td>';
     1109        print '<td>' . esc_html__( 'Run the built-in regression tests against the in-use vesion of WP-GeoMeta-Lib' , 'wp-geometa' ) . '</td></tr>';
     1110
     1111        // Remove WP-GeoMeta Tables.
     1112        print '<tr><td><button data-action="remove-tables" class="wpgm-danger-action">' . esc_html__( 'Remove WP-GeoMeta Tables' , 'wp-geometa' ) . '</button></td>';
     1113        print '<td>' . esc_html__( 'All WP-GeoMeta data is stored in its own tables. Your original data is untouched. Removing WP-GeoMeta tables will break any spatial queries you may be using.' , 'wp-geometa' ) . '</td></tr>';
     1114
     1115        // Create WP-GeoMeta Tables.
     1116        print '<tr><td><button data-action="create-tables" class="wpgm-danger-action">' . esc_html__( 'Create WP-GeoMeta Tables and Functions' , 'wp-geometa' ) . '</button></td>';
     1117        print '<td>' . esc_html__( 'WP-GeoMeta tables are created on plugin activation or upgrade, but you can manually create them here. WP-GeoMeta uses dbDelta, so running this multiple times will have no bad effects.' , 'wp-geometa' ) . '</td></tr>';
     1118
     1119        // Truncate WP-GeoMeta Tables.
     1120        print '<tr><td><button data-action="truncate-tables" class="wpgm-danger-action">' . esc_html__( 'Truncate WP-GeoMeta Tables' , 'wp-geometa' ) . '</button></td>';
    10961121        print '<td>' . esc_html__( 'Clears existing spatial data, but doesn\'t remove the tables.' , 'wp-geometa' ) . '</td></tr>';
    10971122
    1098         // Populate WP GeoMeta Tables.
    1099         print '<tr><td><button data-action="populate-tables" class="wpgm-danger-action">' . esc_html__( 'Populate WP GeoMeta Tables' , 'wp-geometa' ) . '</button></td>';
    1100         print '<td>' . esc_html__( 'Detect any spatial data (GeoJSON) in the non-spatial meta tables which is not stored in WP GeoMeta and load it. This may take a while!', 'wp-geometa' ) . '</td></tr>';
    1101 
    1102         // Populate WP GeoMeta Tables.
     1123        // Populate WP-GeoMeta Tables.
     1124        print '<tr><td><button data-action="populate-tables" class="wpgm-danger-action">' . esc_html__( 'Populate WP-GeoMeta Tables' , 'wp-geometa' ) . '</button></td>';
     1125        print '<td>' . esc_html__( 'Detect any spatial data (GeoJSON) in the non-spatial meta tables which is not stored in WP-GeoMeta and load it. This may take a while!', 'wp-geometa' ) . '</td></tr>';
     1126
     1127        // Populate WP-GeoMeta Tables.
    11031128        print '<tr><td><button data-action="rebuild-function-cache" class="wpgm-danger-action">' . esc_html__( 'Rebuild spatial function cache' , 'wp-geometa' ) . '</button></td>';
    11041129        print '<td>' . esc_html__( 'Re-check and cache which MySQL spatial functions are supported.', 'wp-geometa' ) . '</td></tr>';
     
    11201145     * @param string $metatype The type of object this meta is for (post, user, etc.).
    11211146     */
    1122     public function sample_latlng_to_json( $record, $metatype ) {
     1147    public function wpgmd_sample_data_to_json( $record, $metatype ) {
    11231148        if ( array_key_exists( $record['meta_key'], WP_GeoMeta::$latlngs_index ) ) {
    11241149            $record['meta_value'] = '{"type":"Feature","geometry":' . WP_GeoUtil::geom_to_geojson( $record['geo_meta_value'] ) . ',"properties":[]}'; // @codingStandardsIgnoreLine
  • wp-geometa/trunk/lib/wp-geometa-lib/CHANGELOG.md

    r1557784 r1607853  
    11Changes
    22-------
     3
     4### 0.3.2
     5 * WP_GeoUtil::is_geom now has a shortcircuit for strings that don't even look like WKT
     6 * Updated documentation!
     7 * WP_GeoUtil::run_spatial_query now uses a non-warning-generating method to detect if a value is spatial or not
     8 * Updated WP_GeoUtil::is_geojson to detect non-GeoJSON without trying to parse it.
     9 * Improved metaval_to_geom
     10 * Improved handling of MySQL geometry function call results, wrapping bare geometry GeoJSON with {"type":"Feature", "geometry": {the geometry}}
     11 * Split out creation of tables from creation of custom SQL functions.
     12 * Added filter to allow plugin devs to include their own custom SQL function files.
     13 * Standardized filter name prefixes to wpgm\_ (old filters will stick around for a few versions, even though I don't think anyone is using them).
     14 * Standardized internal callback functions to use the same name as the filter that they're callbacks for.
     15 * Tests are now included and work within WP-GeoMeta-Lib instead of in WP-GeoMeta.
     16 * Allow WP_GeoUtil::get_capabilities to be run without accessing the options table and without caching the results.
     17 * Cleaner loader file, working towards using spl_autoload_register in a future release.
     18 * Only loads geoPHP if it's needed.
    319
    420### 0.3.1
  • wp-geometa/trunk/lib/wp-geometa-lib/HACKING.md

    r1544952 r1607853  
    6868object and array representations of GeoJSON are be accepted.
    6969
    70 WP-GeoMeta stores data in EPSG:4326 by default, which is (a) the default format
     70WP-GeoMeta stores data in EPSG:4326 by default, which is (a) the official format
    7171for GeoJSON and (b) the most common format for web maps.
    7272
     
    7878
    7979See the [README.md](README.md) for examples of how to use WP_GeoQuery.
    80 
    81 Related Projects
    82 ----------------
    83 * https://github.com/cimburadotcom/WP-GeoJSON-Loader
    84 * https://github.com/cimburadotcom/MySQL_Stored_Geo_Functions
    85 * https://github.com/cimburadotcom/wp-spatial-capabilities-check
  • wp-geometa/trunk/lib/wp-geometa-lib/README.md

    r1557784 r1607853  
    1 WP-GeoMeta Lib
     1WP-GeoMeta-Lib
    22==============
    33
    4 WP-GeoMeta is a spatial foundation for WordPress.  It provides a solid foundation
    5 for spatial data using MySQL's native spatial support. With WP-GeoMeta you can store
     4WP-GeoMeta-Lib is a spatial framework for WordPress.  It provides a solid foundation
     5for spatial data using MySQL's native spatial support. With WP-GeoMeta-Lib you can store
    66and search spatial metadata like you do any other metadata, but using MySQL spatial indexes.
    77
    8 WP-GeoMeta was created with developers in mind. If you find it cumbersome, buggy or
     8WP-GeoMeta-Lib was created with developers in mind. If you find it cumbersome, buggy or
    99missing features, let us know!
    1010
     
    1515    - [Writing and Reading Data](#writing-and-reading-data)
    1616    - [Querying](#querying)
    17     - [ORDER BY](#order-by)
     17        - [Support Comparison Operations](#support-comparison-operations)
     18        - [ORDER BY](#order-by)
     19    - [WordPress Hooks](#wordpress-hooks)
     20        - [Filters](#filters)
     21        - [Actions](#actions)
     22    - [Calling Spatial Functions From PHP](#calling-spatial-functions-from-php)
     23        - [Examples](#examples)
     24    - [Custom Auxiliary Functions](#custom-auxiliary-functions)
     25- [Why WP-GeoMeta-Lib?](#why-wp-geometa-lib)
     26    - [Integration with Other Plugins](#integration-with-other-plugins)
     27    - [Why not separate lat and long fields?](#why-not-separate-lat-and-long-fields)
     28        - [OK, fine, but I really need separate fields](#ok-fine-but-i-really-need-separate-fields)
     29- [Important Notes](#important-notes)
    1830- [Server Requirements](#server-requirements)
    1931    - [WordPress](#wordpress)
     32    - [MySQL](#mysql)
    2033    - [PHP](#php)
    21 - [Frequently Asked Questions](#frequently-asked-questions)
    22     - [What spatial comparisons are supported?](#what-spatial-comparisons-are-supported)
    23 - [Hooks: Filters and Actions](#hooks-filters-and-actions)
    24 - [Why WP-GeoMeta?](#why-wp-geometa)
    25     - [Integration with Other Plugins](#integration-with-other-plugins)
    26     - [Why not separate lat and long fields?](#why-not-separate-lat-and-long-fields)
    27     - [OK, fine, but I really need separate fields](#ok-fine-but-i-really-need-separate-fields)
    28 - [How to Use WP-GeoMeta](#how-to-use-wp-geometa)
    29 - [Important Notes](#important-notes)
    3034- [Hacking](#hacking)
    3135- [Quotes](#quotes)
     
    3640-----------
    3741
    38 1. Download WP-GeoMeta Lib to your plugin.
     421. Download WP-GeoMeta-Lib to your plugin.
    3943 
    4044 ```
     
    4751 ```
    4852
    49 3. Save GeoJSON metadata!
     533. Set up an activation hook to install WP_GeoMeta when your plugin activates.
     54
     55 ```
     56   register_activation_hook( __FILE__ , array('WP_GeoMeta','install'));
     57 ```
     58
     59 If you already have your own activation hook, you can simply add WP_GeoMeta::install() to your hook.
     60
     614. Save GeoJSON metadata!
    5062 
    5163 ```
     
    5567Once you are storing spatial data you (or anyone else!) can query it
    5668using spatial queries!
    57 
    5869
    5970Usage
     
    891001. Query comparing geometries
    90101
    91 This style of query is for all spatial functions which accept two geometries as arguments and which
    92 return a boolean as a result. For example ST_INTERSECTS, CONTAINS or MBROverlaps.
    93 
    94 The meta_query _compare_ is the function to use, and the _value_ should be a GeoJSON representation
    95 of the geometry to use for the second argument. The geometry meta field indicated by the _key_ parameter
    96 will be used as the first argument to the _compare_ function.
    97 
     102 This style of query is for all spatial functions which accept two geometries as arguments and which
     103 return a boolean as a result. For example ST_INTERSECTS, CONTAINS or MBROverlaps.
     104 
     105 The meta_query _compare_ is the function to use, and the _value_ should be a GeoJSON representation
     106 of the geometry to use for the second argument. The geometry meta field indicated by the _key_ parameter
     107 will be used as the first argument to the _compare_ function.
     108
     109 ```
    98110    $q = new WP_Query( array(
    99111        'meta_query' => array(
     
    110122        print "\t* " . get_the_title() . "\n";
    111123    }
     124 ```
    112125
    1131262. Query geometry properties
    114127
    115 This style of query is for all spatial functions which accept a single geometry as an argument and
    116 which return a boolean as a result. For example ST_IsSimple, IsClosed or ST_IsEmpty.
    117 
    118 The _compare_ argument should be the function just like above, but no value is needed.
    119 
     128 This style of query is for all spatial functions which accept a single geometry as an argument and
     129 which return a boolean as a result. For example ST_IsSimple, IsClosed or ST_IsEmpty.
     130 
     131 The _compare_ argument should be the function just like above, but no value is needed.
     132
     133 ```
    120134    $q = new WP_Query(array(
    121135        'meta_query' => array(
     
    125139            )
    126140        )));
     141 ```
    127142
    1281433. Compare the results of geometry functions
    129144
    130 This style of query is for spatial functions which accept a single geometry as an argument but return
    131 a non-boolean response. For example, GLength, ST_Area or ST_SRID.
    132 
    133 In these queries you may want to use a normal meta_query comparison (=, >, BETWEEN, etc.) but against
    134 the result of a spatial function. To accomodate this type of case, you will need to add an additional
    135 parameter _geom_op_.
    136 
    137 The _key_, _compare_ and _value_ are used in the regular WP_Query way, but the comparison will be
    138 made against the result of applying the geometry function to the spatial metadata specified.
    139 
     145 This style of query is for spatial functions which accept a single geometry as an argument but return
     146 a non-boolean response. For example, GLength, ST_Area or ST_SRID.
     147 
     148 In these queries you may want to use a normal meta_query comparison (=, >, BETWEEN, etc.) but against
     149 the result of a spatial function. To accomodate this type of case, you will need to add an additional
     150 parameter _geom_op_.
     151 
     152 The _key_, _compare_ and _value_ are used in the regular WP_Query way, but the comparison will be
     153 made against the result of applying the geometry function to the spatial metadata specified.
     154
     155 ```
    140156    $q = new WP_Query(array(
    141157        'meta_query' => array(
     
    147163        )
    148164        )));
    149 
    150 ### ORDER BY
    151 
    152 orderby with named meta clauses should work. It's a new feature though, so send me bug reports.
     165 ```
     166
     167#### Support Comparison Operations
     168
     169Any spatial operation that takes two geometries and returns a boolean,
     170or which takes one geometry and returns a boolean or a value is
     171supported, if your version of MySQL supports it.
     172
     173The following function should work, if your install of MySQL supports them:
     174
     175<table>
     176<tr>
     177<td>Area</td>
     178<td>Contains</td>
     179<td>Crosses</td>
     180<td>Dimension</td>
     181</tr>
     182<tr>
     183<td>Disjoint</td>
     184<td>Equals</td>
     185<td>GLength</td>
     186<td>GeometryType</td>
     187</tr>
     188<tr>
     189<td>Intersects</td>
     190<td>IsClosed</td>
     191<td>IsEmpty</td>
     192<td>IsRing</td>
     193</tr>
     194<tr>
     195<td>IsSimple</td>
     196<td>MBRContains</td>
     197<td>MBRCoveredBy</td>
     198<td>MBRDisjoint</td>
     199</tr>
     200<tr>
     201<td>MBREqual</td>
     202<td>MBREquals</td>
     203<td>MBRIntersects</td>
     204<td>MBROverlaps</td>
     205</tr>
     206<tr>
     207<td>MBRTouches</td>
     208<td>MBRWithin</td>
     209<td>NumGeometries</td>
     210<td>NumInteriorRings</td>
     211</tr>
     212<tr>
     213<td>NumPoints</td>
     214<td>Overlaps</td>
     215<td>SRID</td>
     216<td>ST_Area</td>
     217</tr>
     218<tr>
     219<td>ST_Contains</td>
     220<td>ST_Crosses</td>
     221<td>ST_Difference</td>
     222<td>ST_Dimension</td>
     223</tr>
     224<tr>
     225<td>ST_Disjoint</td>
     226<td>ST_Distance</td>
     227<td>ST_Distance_Sphere</td>
     228<td>ST_Equals</td>
     229</tr>
     230<tr>
     231<td>ST_GeometryType</td>
     232<td>ST_Intersects</td>
     233<td>ST_IsClosed</td>
     234<td>ST_IsEmpty</td>
     235</tr>
     236<tr>
     237<td>ST_IsRing</td>
     238<td>ST_IsSimple</td>
     239<td>ST_IsValid</td>
     240<td>ST_Length</td>
     241</tr>
     242<tr>
     243<td>ST_NumPoints</td>
     244<td>ST_Overlaps</td>
     245<td>ST_SRID</td>
     246<td>ST_Touches</td>
     247</tr>
     248<tr>
     249<td>ST_Within</td>
     250<td>Touches</td>
     251<td>Within</td>
     252<td></td>
     253</tr>
     254</table>
     255
     256To see what your install of MySQL supports, install
     257[WP Spatial Capabilities Check](https://wordpress.org/plugins/wp-spatial-capabilities-check/).
     258We recommend using MySQL 5.6.1 or higher since it included many important updates to
     259spatial operators.
     260
     261#### ORDER BY
     262
     263orderby with named meta clauses should work.
    153264
    1542651) Single arg orderby (eg. Dimension, GLength, ST_Area)
     
    181292
    182293
    183 
    184 Server Requirements
     294### WordPress Hooks
    185295-------------------
    186296
    187 ### WordPress
    188 This library supports storing spatial metadata for posts, users, comments and
    189 terms.
    190 
    191 Setting, getting and querying values should work in 4.1 with some missing functionality.
    192 Running orderby doesn't work until 4.2
    193 Searching term metadata arrived in WordPress 4.4, but other
    194 functionality should still work in older versions of WordPress.
    195 
    196 MySQL 5.6.1 or higher is strongly recommended. Lower than MySQL 5.1.72 is untested.
    197 
    198 WP_GeoMeta will probably work on MySQL 5.4, but spatial support was pretty weak
    199 before version 5.6.1.
    200 
    201 Before MySQL 5.6.1 spatial functions worked against the mininum bounding rectangle
    202 instead of the actual geometry.
    203 
    204 MySQL 5.7 brough spatial indexes to InnoDB tables. Before that only MyISAM tables
    205 supported spatial indexes. Anything else required a full table scan.
    206 
    207 If you are using MySQL 5.7, good for you, and consider converting your geo tables
    208 to InnoDB! (and let me know how it goes).
    209 
    210 ### PHP
    211 PHP 5.2.4 and higher are supported, just like WordPress's minimum version.
    212 Please report any PHP errors you come across and we'll fix them up.
    213 
    214 Frequently Asked Questions
    215 --------------------------
    216 
    217 ### What spatial comparisons are supported?
    218 
    219 Any spatial operation that takes two geometries and returns a boolean,
    220 or which takes one geometry and returns a boolean or a value is
    221 supported, if your version of MySQL supports it.
    222 
    223 The following function should work, if your install of MySQL supports them:
    224 
    225 <table>
    226 <tr>
    227 <td>Area</td>
    228 <td>Contains</td>
    229 <td>Crosses</td>
    230 <td>Dimension</td>
    231 </tr>
    232 <tr>
    233 <td>Disjoint</td>
    234 <td>Equals</td>
    235 <td>GLength</td>
    236 <td>GeometryType</td>
    237 </tr>
    238 <tr>
    239 <td>Intersects</td>
    240 <td>IsClosed</td>
    241 <td>IsEmpty</td>
    242 <td>IsRing</td>
    243 </tr>
    244 <tr>
    245 <td>IsSimple</td>
    246 <td>MBRContains</td>
    247 <td>MBRCoveredBy</td>
    248 <td>MBRDisjoint</td>
    249 </tr>
    250 <tr>
    251 <td>MBREqual</td>
    252 <td>MBREquals</td>
    253 <td>MBRIntersects</td>
    254 <td>MBROverlaps</td>
    255 </tr>
    256 <tr>
    257 <td>MBRTouches</td>
    258 <td>MBRWithin</td>
    259 <td>NumGeometries</td>
    260 <td>NumInteriorRings</td>
    261 </tr>
    262 <tr>
    263 <td>NumPoints</td>
    264 <td>Overlaps</td>
    265 <td>SRID</td>
    266 <td>ST_Area</td>
    267 </tr>
    268 <tr>
    269 <td>ST_Contains</td>
    270 <td>ST_Crosses</td>
    271 <td>ST_Difference</td>
    272 <td>ST_Dimension</td>
    273 </tr>
    274 <tr>
    275 <td>ST_Disjoint</td>
    276 <td>ST_Distance</td>
    277 <td>ST_Distance_Sphere</td>
    278 <td>ST_Equals</td>
    279 </tr>
    280 <tr>
    281 <td>ST_GeometryType</td>
    282 <td>ST_Intersects</td>
    283 <td>ST_IsClosed</td>
    284 <td>ST_IsEmpty</td>
    285 </tr>
    286 <tr>
    287 <td>ST_IsRing</td>
    288 <td>ST_IsSimple</td>
    289 <td>ST_IsValid</td>
    290 <td>ST_Length</td>
    291 </tr>
    292 <tr>
    293 <td>ST_NumPoints</td>
    294 <td>ST_Overlaps</td>
    295 <td>ST_SRID</td>
    296 <td>ST_Touches</td>
    297 </tr>
    298 <tr>
    299 <td>ST_Within</td>
    300 <td>Touches</td>
    301 <td>Within</td>
    302 <td></td>
    303 </tr>
    304 </table>
    305 
    306 To see what your install of MySQL supports, install
    307 [WP Spatial Capabilities Check](https://wordpress.org/plugins/wp-spatial-capabilities-check/).
    308 We recommend using MySQL 5.6.1 or higher since it included many important updates to
    309 spatial operators.
    310 
    311 Hooks: Filters and Actions
    312 --------------------------
    313 
    314  * *Filter*: wpgm_pre_metaval_to_geom
     297The power of WordPress come partly from its Hooks system. WP-GeoMeta-Lib tries to provide the neccessary hooks
     298so that you can extend it to suit your needs. If there's a hook that you need send me a pull request or file an issue.
     299
     300#### Filters
     301
     302 * wpgm_pre_metaval_to_geom
    315303
    316304 This filter is called right before WP-GeoMeta tries to convert the incoming meta value
     
    343331 ```
    344332
    345  * *Filter*: wpgm_pre_delete_geometa
     333 * wpgm_pre_delete_geometa
    346334
    347335 This filter is called after a meta value has been deleted from the regular meta table, right
     
    373361 ```
    374362
    375  * *Filter*: wp_geoquery_srid
     363 * wpgm_geoquery_srid
    376364
    377365 This filter is called during plugins_loaded. It sets the [SRID](https://en.wikipedia.org/wiki/Spatial_reference_system)
     
    383371 you know what you're doing.
    384372
    385  * *Filter*: wpgq_metaval_to_geom
     373 * wpgm_metaval_to_geom
    386374
    387375 This filter is called within WP_GeoUtil::metaval_to_geom. It offers an opportunity to
     
    393381 Usage:
    394382 ```
    395     add_filter( 'wpgq_metaval_to_geom', 'kml_to_geometry' );
     383    add_filter( 'wpgm_metaval_to_geom', 'kml_to_geometry' );
    396384
    397385    /**
     
    410398 ```
    411399
    412  * *Filter*: wpgq_geom_to_geojson
     400 * wpgm_geom_to_geojson
    413401
    414402 This filter is called when converting a geometry from the database into GeoJSON
     
    420408 Usage:
    421409 ```
    422     add_filter( 'wpgq_geom_to_geojson', 'myplugin_geom_to_geojson' );
     410    add_filter( 'wpgm_geom_to_geojson', 'myplugin_geom_to_geojson' );
    423411
    424412    /**
     
    434422 ```
    435423
    436  * *Filter*: wpgmd_sample_data_to_json
    437 
    438  This filter is called when loading a random sample of data for the map of spatial data
    439  in the dashboard. It is used internally to create a GeoJSON representation of lat/lng
    440  fields for display on the map.
    441 
    442  Usage:
    443  ```
    444     add_filter( 'wpgmd_sample_data_to_json', 'custom_sample_data' );
    445 
    446     /**
    447      *
    448      * @param array $record A single database query result array.
    449      * $record['the_id'] -- The object ID the metadata belongs to
    450      * $record['meta_key'] -- The meta_key for the metadata (from the postmeta (etc.) table, not the possibly modified version in the postmeta_geo (etc.) table )
    451      * $record['meta_value'] -- The meta_value for the metadata (from the postmeta (etc.) table, not the spatial version from the postmeta_geo (etc.) table)
    452      * $record['geo_meta_value'] -- The meta_value from the postmeta_geo (etc.) table
    453      * $record['geo_meta_key'] -- The meta_key from the postmeta_geo (etc.) table
    454      *
    455      * @param string $metatype The type of object this meta is for (post, user, etc.)
    456      */
    457     function custom_sample_data( $record, $metatype ) {
    458         if ( 'my_special_geo_meta_key' === $record[ 'geo_meta_key'] ) {
    459             // Do something.
    460             $record[ 'meta_value' ] = my_custom_geojson( $record[ 'geo_meta_value' ] );
    461         }
    462 
    463         return $record;
    464     }
    465  ```
    466 
    467  * *Filter*: wpgq_known_capabilities
     424 * wpgm_known_capabilities
    468425
    469426 This filter is available so you can make your custom MySQL functions known to other users of WP-GeoMeta-Lib.
     
    479436 Usage:
    480437 ```
    481     add_filter( 'wpgq_known_capabilities', 'myplugin_add_support_for_my_func' );
     438    add_filter( 'wpgm_known_capabilities', 'myplugin_add_support_for_my_func' );
    482439
    483440    function myplugin_add_support_for_my_func( $all_funcs ) {
     
    496453 ```
    497454
    498  * *Action*: wpgm_populate_geo_tables
     455 * wpgm_extra_sql_functions
     456
     457 This filter allows you to add additional custom SQL functions to MySQL. Combined with wpgm_known_capabilites
     458 you can fully integrate your custom SQL into WP-GeoMeta-Lib.
     459
     460 This filter produces an array of file system paths to files containing SQL functions. The files should use
     461`$$` as the delimiter for the function. Please see any of the .sql files in this project for examples.
     462
     463 Usage:
     464 ```
     465    add_filter( 'wpgm_extra_sql_functions', 'myplugin_add_extra_sql' );
     466
     467    function myplugin_add_extra_sql( $all_sql_files ) {
     468
     469        $my_sql_files = array(
     470            'custom_func1.sql',
     471            'custom_func2.sql'
     472        );
     473
     474        foreach( $my_sql_files as $my_file ) {
     475            $full_path = dirname( __FILE__ ) . '/sql/' . $my_file;
     476
     477            if ( !in_array( $full_path, $all_sql_files ) ) {
     478                $all_sql_files[] = $full_path;
     479            }
     480        }
     481
     482        return $all_sql_files;
     483    }
     484 ```
     485
     486#### Actions
     487
     488 * wpgm_populate_geo_tables
    499489
    500490 This action is called at the end of WP_GeoMeta->populate_geo_tables() to give you
     
    525515
    526516
    527 
    528 Why WP-GeoMeta?
    529 ---------------
     517### Calling Spatial Functions From PHP
     518
     519 Sometimes you might just need to run a spatial operation on a spatial value. WP-GeoMeta-Lib makes
     520 this easy!
     521
     522 You can call any spatial function your install of MySQL supports as a static method of WP_GeoUtil.
     523 These functions conveniently accept GeoJSON geometry so you don't have to convert your spatial
     524 data into Well Known Text (WKT) for MySQL.
     525
     526#### Examples
     527
     528 Check if two GeoJSON shapes intersect
     529 ```
     530 $do_they_intersect = WP_GeoUtil::ST_Intersects({PointGeoJSON},{PolygonGeoJSON});
     531 ```
     532
     533 Union (combine) two GeoJSON polygons
     534 ```
     535 $spatial_union = WP_GeoUtil::ST_Union({PolygonGeoJSON_1},{PolygonGeoJSON_2});
     536 ```
     537
     538### Custom Auxiliary Functions
     539
     540 Besides the default spatial functions included with MySQL, WP-GeoMeta-Lib
     541 provides the filter wpgq_known_capabilities which lets you add support
     542 for your own spatial SQL functions. These can be UDF (User Defined Functions) or Stored Functions.
     543
     544 WP-GeoMeta-Lib includes several stored functions for your convenience.
     545
     546 The functions included are:
     547
     548 * **wp_buffer_point_m( p POINT, radius FLOAT, segments INT)**
     549
     550    Buffer a point by a number of meters. Returns a polygon approximating a circle.
     551
     552    - _p_ A single point geometry with coordinates in EPSG:4326 (the common latitude/longitude format, like 45.0,-93.3)
     553    - _radius_ The distance to buffer the point, in meters.
     554    - _segments_ The number of segments per quarter of a circle. Eg. If you set this to 4, then your resulting polygon will have 16 segments.
     555
     556 * **wp_buffer_point_mi( p POINT, radius FLOAT, segments INT)**
     557
     558    Buffer a point by a number of miles. Returns a polygon approximating a circle.
     559
     560    - _p_ A single point geometry with coordinates in EPSG:4326.
     561    - _radius_ The distance to buffer the point, in miles.
     562    - _segments_ The number of segments per quarter of a circle. Eg. If you set this to 4, then your resulting polygon will have 16 segments.
     563
     564 * **wp_buffer_point_real( p POINT, radius FLOAT, segments INT, eradius INTEGER)**
     565
     566    Buffer a point assuming an earth with a specified radius. Returns a polygon approximating a circle.
     567
     568    - _p_ A single point geometry with coordinates in EPSG:4326.
     569    - _radius_ The distance to buffer the point, in any units.
     570    - _segments_ The number of segments per quarter of a circle. Eg. If you set this to 4, then your resulting polygon will have 16 segments.
     571    - _eradius_ The radius of the earth in the same units as _radius_
     572
     573 * **wp_distance_point_m( p1 POINT, p2 POINT)**
     574   
     575    Get the distance between two points in meters.
     576
     577    - _p1_ A single point geometry with coordinates in EPSG:4326.
     578    - _p2_ A single point geometry with coordinates in EPSG:4326.
     579
     580 * **wp_distance_point_mi( p1 POINT, p2 POINT)**
     581   
     582    Get the distance between two points in miles.
     583
     584    - _p1_ A single point geometry with coordinates in EPSG:4326.
     585    - _p2_ A single point geometry with coordinates in EPSG:4326.
     586
     587 * **wp_distance_point_real( p1 POINT, p2 POINT, radius FLOAT)**
     588
     589    Get the distance between two points for a given radius of the earth.
     590
     591    - _p1_ A single point geometry with coordinates in EPSG:4326.
     592    - _p2_ A single point geometry with coordinates in EPSG:4326.
     593    - _radius_ The radius of the earth in the units you want your results in.
     594
     595 * **wp_first_geom( p GEOMETRY )**
     596
     597    Get the first geometry from a multi-geometry. If _p_ is not a multi-geometry, it will be returned unchanged.
     598
     599    - _p_ A geometry object.
     600
     601 * **wp_point_bearing_distance_to_line_m(p POINT, bearing FLOAT, distance FLOAT)**
     602
     603    Create a linestring given a starting point, a bearing and a distance in meters.
     604
     605    _p_ A single point geometry with coordinates in EPSG:4326.
     606    _bearing_ The bearing to travel in degrees. 0 degrees is north.
     607    _distance_ The number of meters to travel.
     608
     609 * **wp_point_bearing_distance_to_line_mi(p POINT, bearing FLOAT, distance FLOAT)**
     610
     611    Create a linestring given a starting point, a bearing and a distance in miles.
     612
     613    _p_ A single point geometry with coordinates in EPSG:4326.
     614    _bearing_ The bearing to travel in degrees. 0 degrees is north.
     615    _distance_ The number of miles to travel.
     616
     617 * **wp_point_bearing_distance_to_line(p POINT, bearing FLOAT, distance FLOAT, eradius INTEGER)**
     618
     619    Create a linestring given a starting point, a bearing, a distance and the radius of the earth.
     620
     621    _p_ A single point geometry with coordinates in EPSG:4326.
     622    _bearing_ The bearing to travel in degrees. 0 degrees is north.
     623    _distance_ The distance to travel.
     624    _eradius_ The radius of the earth in the same units as _distance_.
     625
     626
     627 * **wp_point_bearing_distance_coord_pair(p POINT, bearing FLOAT, distance FLOAT, eradius INTEGER)**
     628
     629    Get the point a given distance from a starting point on a given bearing for a given radius of the earth.
     630
     631    _p_ A single point geometry with coordinates in EPSG:4326.
     632    _bearing_ The bearing to travel in degrees. 0 degrees is north.
     633    _distance_ The distance to travel.
     634    _eradius_ The radius of the earth in the same units as _distance_.
     635
     636
     637Why WP-GeoMeta-Lib?
     638-------------------
     639
     640If your plugin or website uses location data, then you should be using WP-GeoMeta-Lib. WP-GeoMeta-Lib
     641makes using spatial data *easy* and *efficient*.
     642
     643All metadata goes into a big meta table, regardless of what type of data it is.  All values are stored
     644as longtext and there's not even an index on the column. This is fine for looking up values if you
     645know the post ID and the key name. It's less than ideal if you need to search for a certain value
     646and it's absolutely terrible if you want to store or search for spatial data.
     647
     648WP-GeoMeta-Lib detects when you are storing or querying spatial data and transparently re-routes those
     649data and queries to a set of spatial metadata tables. These spatial metadata tables are indexed and give you
     650the ability to use all of the spatial functions built in to MySQL.
     651
    530652
    531653### Integration with Other Plugins
    532654
    533 You might not need spatial queries yourself, but by using WP-GeoMeta you allow other developers to
     655Even if you don't need spatial queries yourself, using WP-GeoMeta-Lib allows other developers to
    534656query your data more easily.
    535657
     
    543665Storing lat and long in separate fields means that you have to implement your own
    544666[complicated queries](http://stackoverflow.com/questions/20795835/wordpress-and-haversine-formula)
    545 if you want to search by distance.
    546 
    547 You'll only be able to store points, and you won't have indexing available.
    548 
    549 ### OK, fine, but I really need separate fields
    550 
     667if you want to search by distance. You won't be able to store lines or polygons,
     668there's no indexing on your points and geographers everywhere will cry.
     669
     670#### OK, fine, but I really need separate fields
     671
     672If you really need (or already are using) separate longitude and latitude fields
    551673Using separate Latitude and Longitude fields is slightly more complex, but is
    552674supported by WP-GeoMeta. You will need to register your new latitude/longitude
     
    573695supported out of the box.
    574696
    575 How to Use WP-GeoMeta
    576 ---------------------
    577 
    578 1. Download [the latest version](https://github.com/cimburadotcom/WP-GeoMeta/releases) of WP-GeoMeta to
    579 a sub-directory inside your plugin — ```myplugin/wp-geometa```
    580 
    581 2. Within your plugin require *wp-geometa.php* — ```require_once( dirname( __FILE__ ) . 'wp-geometa/wp-geometa.php' )```
    582 
    583 3. Add an activation hook to your plugin to create the spatial tables
    584 
    585 ```
    586     function my_activation_hook() {
    587         $wpgeo = WP_GeoMeta::get_instance();
    588         $wpgeo->create_geo_tables();
    589     }
    590     register_activation_hook( __FILE__ , 'my_activation_hook' );
    591 ```
    592 
    593 
    594 4. Use the usual postmeta functions within your plugin (update_post_meta, update_user_meta, etc.)
    595    using GeoJSON as the values.
    596 
    597 5. See the [README.md](README.md) document for instructions on how to query your data.
    598 
    599 
    600697Important Notes
    601698---------------
     
    608705* Some MySQL spatial functions only work on the Bounding Box of the shape and not the actual geometry. For details about
    609706when and why this is a problem, see [this 2013 blog post from Percona](https://www.percona.com/blog/2013/10/21/using-the-new-mysql-spatial-functions-5-6-for-geo-enabled-applications/).
     707
     708Server Requirements
     709-------------------
     710
     711### WordPress
     712This library supports storing spatial metadata for posts, users, comments and
     713terms.
     714
     715Setting, getting and querying values should work in 4.1 with some missing functionality.
     716Running orderby doesn't work until 4.2
     717Searching term metadata arrived in WordPress 4.4, but other
     718functionality should still work in older versions of WordPress.
     719
     720### MySQL
     721
     722MySQL 5.6.1 or higher is strongly recommended. Lower than MySQL 5.1.72 is untested.
     723
     724WP_GeoMeta will probably work on MySQL 5.4, but spatial support was pretty weak
     725before version 5.6.1.
     726
     727Before MySQL 5.6.1 spatial functions worked against the mininum bounding rectangle
     728instead of the actual geometry.
     729
     730MySQL 5.7 brough spatial indexes to InnoDB tables. Before that only MyISAM tables
     731supported spatial indexes. Anything else required a full table scan.
     732
     733If you are using MySQL 5.7, good for you, and consider converting your geo tables
     734to InnoDB! (and let me know how it goes).
     735
     736### PHP
     737PHP 5.2.4 and higher are supported, just like WordPress's minimum version.
     738Please report any PHP errors you come across and we'll fix them up.
    610739
    611740Hacking
  • wp-geometa/trunk/lib/wp-geometa-lib/geoPHP/geoPHP.inc

    r1544952 r1607853  
    99
    1010// Adapters
    11 include_once("lib/adapters/GeoAdapter.class.php"); // Abtract class
    12 include_once("lib/adapters/GeoJSON.class.php");
    13 include_once("lib/adapters/WKT.class.php");
    14 include_once("lib/adapters/EWKT.class.php");
    15 include_once("lib/adapters/WKB.class.php");
    16 include_once("lib/adapters/EWKB.class.php");
    17 include_once("lib/adapters/KML.class.php");
    18 include_once("lib/adapters/GPX.class.php");
    19 include_once("lib/adapters/GeoRSS.class.php");
    20 include_once("lib/adapters/GoogleGeocode.class.php");
    21 include_once("lib/adapters/GeoHash.class.php");
     11include_once(dirname(__FILE__) . "/lib/adapters/GeoAdapter.class.php"); // Abtract class
     12include_once(dirname(__FILE__) . "/lib/adapters/GeoJSON.class.php");
     13include_once(dirname(__FILE__) . "/lib/adapters/WKT.class.php");
     14include_once(dirname(__FILE__) . "/lib/adapters/EWKT.class.php");
     15include_once(dirname(__FILE__) . "/lib/adapters/WKB.class.php");
     16include_once(dirname(__FILE__) . "/lib/adapters/EWKB.class.php");
     17include_once(dirname(__FILE__) . "/lib/adapters/KML.class.php");
     18include_once(dirname(__FILE__) . "/lib/adapters/GPX.class.php");
     19include_once(dirname(__FILE__) . "/lib/adapters/GeoRSS.class.php");
     20include_once(dirname(__FILE__) . "/lib/adapters/GoogleGeocode.class.php");
     21include_once(dirname(__FILE__) . "/lib/adapters/GeoHash.class.php");
    2222
    2323// Geometries
    24 include_once("lib/geometry/Geometry.class.php"); // Abtract class
    25 include_once("lib/geometry/Point.class.php");
    26 include_once("lib/geometry/Collection.class.php"); // Abtract class
    27 include_once("lib/geometry/LineString.class.php");
    28 include_once("lib/geometry/MultiPoint.class.php");
    29 include_once("lib/geometry/Polygon.class.php");
    30 include_once("lib/geometry/MultiLineString.class.php");
    31 include_once("lib/geometry/MultiPolygon.class.php");
    32 include_once("lib/geometry/GeometryCollection.class.php");
     24include_once(dirname(__FILE__) . "/lib/geometry/Geometry.class.php"); // Abtract class
     25include_once(dirname(__FILE__) . "/lib/geometry/Point.class.php");
     26include_once(dirname(__FILE__) . "/lib/geometry/Collection.class.php"); // Abtract class
     27include_once(dirname(__FILE__) . "/lib/geometry/LineString.class.php");
     28include_once(dirname(__FILE__) . "/lib/geometry/MultiPoint.class.php");
     29include_once(dirname(__FILE__) . "/lib/geometry/Polygon.class.php");
     30include_once(dirname(__FILE__) . "/lib/geometry/MultiLineString.class.php");
     31include_once(dirname(__FILE__) . "/lib/geometry/MultiPolygon.class.php");
     32include_once(dirname(__FILE__) . "/lib/geometry/GeometryCollection.class.php");
    3333
    3434class geoPHP
  • wp-geometa/trunk/lib/wp-geometa-lib/wp-geometa-lib-loader.php

    r1557784 r1607853  
    11<?php
    2 
    32/**
    4  * This is the loader file for WP-GeoMeta-lib.
     3 * This is the loader file for WP-GeoMeta-lib.
     4 *
     5 * @package wp-geometa-lib
     6 *
     7 * Version: 0.3.2
    58 *
    69 * To include spatial metadata support in your plugin, simply include this file.
     
    811 * WP-GeoMeta-lib handles having multiple versions of itself installed corretly, always loading the latest version.
    912 *
    10  * It also handles setting up the spatial meta tables, so this file should be included directly, and not inside a hook or action
    11  *
     13 * It also handles setting up the spatial meta tables, so this file should be included directly, and not inside a hook or action.
    1214 */
    13 
    1415
    1516defined( 'ABSPATH' ) or die( 'No direct access' );
    1617
    17 $wp_geometa_version = '0.3.1'; // Also change down in wp_geometa_load_older_version()
     18$wp_geometa_version = '0.3.2';
     19
     20if ( ! class_exists( 'WP_GeoMeta_Installs' ) ) {
     21    /**
     22     * This class is deliberately simple, because if it ever changes
     23     * the changes need to be backwards compatible.
     24     *
     25     * We're using a singleton instead of a global array to capture
     26     * each WP-GeoMeta's version and location.
     27     */
     28    class WP_GeoMeta_Installs {
     29        /**
     30         * List of installs
     31         *
     32         * @var $installs
     33         */
     34        public static $installs = array();
     35
     36        /**
     37         * List of versions
     38         *
     39         * @var $versions
     40         */
     41        public static $versions = array();
     42
     43        /**
     44         * Add an install listing
     45         *
     46         * @param string $file __FILE__ of wp-geometa.php.
     47         * @param string $version the version of wp-geometa.php.
     48         */
     49        public static function add( $file, $version ) {
     50            WP_GeoMeta_Installs::$installs[ $file ] = $version;
     51            WP_GeoMeta_Installs::$versions[ $version ] = $file;
     52        }
     53
     54        /**
     55         * Get the list of installs with versions.
     56         */
     57        public static function get_list() {
     58            return WP_GeoMeta_Installs::$installs;
     59        }
     60
     61        /**
     62         * A loader function for apl_autoload_register.
     63         *
     64         * This gets called by PHP if LeafletPHP is not a class.
     65         *
     66         * This is preferable to always loading the class, since
     67         * this will avoid loading it if it's not needed.
     68         *
     69         * @param string $class_name The class name that PHP is looking for.
     70         */
     71        public static function load( $class_name ) {
     72            if ( in_array( $class_name, array( 'WP_GeoMeta', 'WP_GeoQuery', 'WP_GeoUtil' ), true ) ) {
     73                WP_GeoMeta_Installs::load_now();
     74            }
     75        }
     76
     77        /**
     78         * This method will go away eventually.
     79         */
     80        public static function load_now() {
     81            // Sort keys by version_compare.
     82            uksort( WP_GeoMeta_Installs::$versions, 'version_compare' );
     83
     84            // Go to the end of the array and require the file.
     85            // Then get the directory.
     86            $this_dir = dirname( end( WP_GeoMeta_Installs::$versions ) );
     87
     88            // Require the wp-geometa-lib file which will handle DB upgrades, initializing stuff and setting up needed hooks.
     89            require_once( $this_dir . '/wp-geometa-lib.php' );
     90        }
     91    }
     92
     93    // Let PHP auto loading only include the file if needed.
     94    spl_autoload_register( array( 'WP_GeoMeta_Installs', 'load' ) );
     95
     96    add_action( 'plugins_loaded', array( 'WP_GeoMeta_Installs', 'load_now' ) );
     97}
     98
     99// Add ourself to the list of installs.
     100WP_GeoMeta_Installs::add( __FILE__, $wp_geometa_version );
    18101
    19102/**
    20  * Gather some self metadata so that if WP-GeoMeta is included as a lib in multiple plugins
    21  * and/or as a plugin itself, we can determine which one to load.
     103 * Legacy handling
     104 *
     105 * If we detect an older version of WP_GeoMeta, do the old stuff to make sure we get loaded.
    22106 */
    23107$wp_geometa_max_version = get_option( 'wp_geometa_version', '0.0.0' );
    24 $wp_geometa_db_version = get_option( 'wp_geometa_db_version', '0.0.0' );
    25108
    26109/**
     
    29112 * 1 means our version is higher.
    30113 */
    31 $wp_geometa_version_status = version_compare( $wp_geometa_version, $wp_geometa_max_version );
     114if ( '0.0.0' !== $wp_geometa_max_version && 1 === version_compare( $wp_geometa_version, $wp_geometa_max_version ) ) {
     115    require_once( dirname( __FILE__ ) . '/wp-geometa-lib.php' );
    32116
     117    if ( ! function_exists( 'wp_geometa_load_older_version' ) ) {
     118        /**
     119         * Do nothing, just stop older versions from defining this function which would cause them to load.
     120         */
     121        function wp_geometa_load_older_version() {
     122        }
     123    }
    33124
    34 // If our version is higher than the version in wp_options, then bump the DB version
    35 // so that our verison will be the one to load next time.
    36 if ( 1 === $wp_geometa_version_status ) {
    37     update_option( 'wp_geometa_version', $wp_geometa_version );
    38 }
    39 
    40 // If our version is equal or higher to the db version, try to load our instance
    41 if ( 0 >= $wp_geometa_version_status || '0.0.0' === $wp_geometa_max_version ) {
    42 
    43     // Other instances of WP_GeoMeta shouldn't have loaded these classes
    44     // unless they're the same version as this instance.
    45     if ( ! class_exists( 'WP_GeoMeta' ) ) {
    46         require_once( dirname( __FILE__ ) . '/wp-geoquery.php' );
    47         require_once( dirname( __FILE__ ) . '/wp-geometa.php' );
    48         $wpgeo = WP_GeoMeta::get_instance();
    49         $wpgq = WP_GeoQuery::get_instance();
    50 
    51         define( 'WP_GEOMETA_VERSION', $wp_geometa_version );
    52 
    53         // Since we just got loaded, make sure that the database reflects any
    54         // changes that the latest version of WP_GeoMeta might have added.
    55         $db_version_compare = version_compare( $wp_geometa_version, $wp_geometa_db_version );
    56         if ( $db_version_compare > 0 ) {
    57             $wpgeo->create_geo_tables();
    58 
    59             $wp_geoutil = WP_GeoUtil::get_instance();
    60             $wp_geoutil->get_capabilities( true );
    61             update_option( 'wp_geometa_db_version', $wp_geometa_version );
     125    if ( ! function_exists( 'wpgeometa_setup_latlng_fields' ) ) {
     126        /**
     127         * Do nothing, just stop older versions from defining this function.
     128         */
     129        function wpgeometa_setup_latlng_fields() {
    62130        }
    63131    }
    64132}
    65 
    66 /**
    67  * There's a chance that someone installed a newer version of the plugin,
    68  * (or a plugin that used the library) which caused the option to get set,
    69  * then removed that plugin, which would mean that we aren't loading the
    70  * usual way.
    71  *
    72  * Add an action to try to load our classes after the rest of the plugins
    73  * get a chance to load.
    74  */
    75 if ( ! function_exists( 'wp_geometa_load_older_version' ) ) {
    76     /**
    77      * Load this instance's libraries.
    78      */
    79     function wp_geometa_load_older_version() {
    80         if ( ! class_exists( 'WP_GeoMeta' ) ) {
    81 
    82             require_once( dirname( __FILE__ ) . '/wp-geoquery.php' );
    83             require_once( dirname( __FILE__ ) . '/wp-geometa.php' );
    84             $wpgeo = WP_GeoMeta::get_instance();
    85             $wpgq = WP_GeoQuery::get_instance();
    86 
    87             $wp_geometa_version = '0.3.1';
    88             $wp_geometa_max_version = get_option( 'wp_geometa_version', '0.0.0' );
    89             $wp_geometa_db_version = get_option( 'wp_geometa_db_version', '0.0.0' );
    90 
    91             // Since we just got loaded, make sure that the database reflects any
    92             // changes that the latest version of WP_GeoMeta might have added.
    93             $db_version_compare = version_compare( $wp_geometa_version, $wp_geometa_db_version );
    94             if ( 0 > $db_version_compare ) {
    95                 $wpgeo->create_geo_tables();
    96 
    97                 $wp_geoutil = WP_GeoUtil::get_instance();
    98                 $wp_geoutil->get_capabilities( true );
    99                 update_option( 'wp_geometa_db_version', $wp_geometa_version );
    100             }
    101 
    102             /*
    103              * If we got downgraded, then the first found wp-geometa will have been
    104              * loaded. Lowering the version to this instance's version will allow
    105              * WP GeoMeta to pick the highest version again on the next run.
    106              *
    107              * Eg. This is v5 and is the first one that WP finds. v6 is also installed
    108              * and v7 was installed. When v7 is no longer found, this (v5) will run since
    109              * it was the first one found and will set wp_geometa_version to v5.
    110              *
    111              * On the next run, it would find that v6 is the higher version and would update
    112              * wp_geometa_version. On the run after that v6 would be loaded.
    113              */
    114             update_option( 'wp_geometa_version', $wp_geometa_version );
    115         }
    116     }
    117     add_action( 'plugins_loaded', 'wp_geometa_load_older_version' );
    118 }
    119 
    120 
    121 /**
    122  * Handle tasks that only matter if we're on the dashboard.
    123  *
    124  * The dashboard allows some actions that should be admin only.
    125  */
    126 if ( is_admin() ) {
    127     if ( ! class_exists( 'WP_GeoMeta_Installs' ) ) {
    128         /**
    129          * This class is deliberately simple, because if it ever changes
    130          * the changes need to be backwards compatible.
    131          *
    132          * We're using a singleton instead of a global array to capture
    133          * each WP-GeoMeta's version and location.
    134          */
    135         class WP_GeoMeta_Installs {
    136             /**
    137              * Singleton variable
    138              *
    139              * @var $_instance
    140              */
    141             private static $_instance = null;
    142 
    143             /**
    144              * Get the singleton instance.
    145              */
    146             public static function get_instance() {
    147                 return ( is_null( self::$_instance ) ? new self : self::$_instance );
    148             }
    149 
    150             /**
    151              * Add an install listing
    152              *
    153              * @param string $file __FILE__ of wp-geometa.php.
    154              * @param string $version the version of wp-geometa.php.
    155              */
    156             public static function add( $file, $version ) {
    157                 $self = self::$_instance = WP_GeoMeta_Installs::get_instance();
    158                 $self->installs[ $file ] = $version;
    159             }
    160 
    161             /**
    162              * Get the list of installs with versions.
    163              */
    164             public static function get_list() {
    165                 $self = WP_GeoMeta_Installs::get_instance();
    166                 return $self->installs;
    167             }
    168         }
    169     }
    170 
    171     // Add ourself to the list of installs.
    172     WP_GeoMeta_Installs::add( __FILE__, $wp_geometa_version );
    173 }
    174 
    175 /**
    176  * Set up an activation hook for when this is a plugin.
    177  *
    178  * Plugins using this as a lib should run $wpgeo->create_geo_tables() themselves
    179  */
    180 if ( ! function_exists( 'wpgeometa_activation_hook' ) ) {
    181     /**
    182      * Simple callback for the activation hook. Creates the spatial tables.
    183      */
    184     function wpgeometa_activation_hook() {
    185         require_once( dirname( __FILE__ ) . '/wp-geometa.php' );
    186         $wpgeo = WP_GeoMeta::get_instance();
    187         $wpgeo->create_geo_tables();
    188     }
    189     register_activation_hook( __FILE__ , 'wpgeometa_activation_hook' );
    190 }
    191 
    192 /**
    193  * Set up handling for standard latlng fields
    194  */
    195 if ( ! function_exists( 'wpgeometa_setup_latlng_fields' ) ) {
    196     /**
    197      * A simple callback function to register the WordPress Geodata standard latitude and longitude fields
    198      *
    199      * See also https://codex.wordpress.org/Geodata for more info.
    200      */
    201     function wpgeometa_setup_latlng_fields() {
    202         WP_GeoMeta::add_latlng_field( 'geo_latitude', 'geo_longitude', 'geo_' );
    203     }
    204     add_action( 'init', 'wpgeometa_setup_latlng_fields' );
    205 }
  • wp-geometa/trunk/lib/wp-geometa-lib/wp-geometa.php

    r1557784 r1607853  
    11<?php
    22/**
    3  * This class handles creating spatial tables saving geo metadata
     3 * This class handles creating spatial tables and saving geo metadata
    44 *
    55 * @package wp-geometa
     
    1010 */
    1111
    12 defined( 'ABSPATH' ) or die( 'No direct access' );
    13 
    14 /**
    15  * This class uses GeoUtil
    16  */
    17 require_once( dirname( __FILE__ ) . '/wp-geoutil.php' );
    18 
    1912/**
    2013 * WP_GeoMeta is responsible for detecting when the user
     
    2417class WP_GeoMeta {
    2518    /**
     19     * The version of WP_GeoMeta.
     20     *
     21     * Gets set by autoloader
     22     *
     23     * @var $version
     24     */
     25    public static $version;
     26
     27    /**
    2628     * Seems like if we call dbDelta twice in rapid succession then we end up
    2729     * with a MySQL error, at least on MySQL 5.5. Other versions untested.
     
    6971    public static $latlngs_index = array();
    7072
     73    /**
     74     * List of extra SQL files to load.
     75     *
     76     * @var $extra_sql
     77     */
     78    private $extra_sql = array( 'first_geometry.sql', 'buffer_point.sql' , 'distance_point.sql', 'point_bearing_distance.sql' );
    7179
    7280    /**
     
    8593        }
    8694
     95        if ( ! defined( 'WP_GEOMETA_VERSION' ) && ! empty( WP_GeoMeta::$version ) ) {
     96            define( 'WP_GEOMETA_VERSION', WP_GeoMeta::$version );
     97        }
     98
    8799        return self::$_instance;
    88100    }
     
    100112        }
    101113
    102         add_filter( 'wpgm_pre_metaval_to_geom', array( $this, 'handle_latlng_meta' ), 10, 2 );
    103         add_filter( 'wpgm_populate_geo_tables', array( $this, 'populate_latlng_geo' ) );
    104         add_filter( 'wpgm_pre_delete_geometa', array( $this, 'delete_latlng_geo' ), 10, 5 );
     114        WP_GeoMeta::add_latlng_field( 'geo_latitude', 'geo_longitude', 'geo_' );
     115
     116        add_filter( 'wpgm_pre_metaval_to_geom', array( $this, 'wpgm_pre_metaval_to_geom' ), 10, 2 );
     117        add_filter( 'wpgm_populate_geo_tables', array( $this, 'wpgm_populate_geo_tables' ) );
     118        add_filter( 'wpgm_pre_delete_geometa', array( $this, 'wpgm_pre_delete_geometa' ), 10, 5 );
     119        add_filter( 'wpgm_extra_sql_functions', array( $this, 'wpgm_extra_sql_functions' ) );
     120    }
     121
     122    /**
     123     * Install the tables and custom SQL queries
     124     */
     125    public static function install() {
     126        $wpgm = WP_GeoMeta::get_instance();
     127        update_option( 'wp_geometa_db_version', WP_GEOMETA_VERSION );
     128
     129        // This will go away once autoloading is configured.
     130        update_option( 'wp_geometa_version', WP_GEOMETA_VERSION );
     131        $wpgm->create_geo_tables();
     132        $wpgm->install_extra_sql_functions();
     133    }
     134
     135    /**
     136     * Upgrade databases, if they exist.
     137     */
     138    public function upgrade() {
     139        $this->create_geo_tables();
     140        $this->install_extra_sql_functions();
     141
     142        update_option( 'wp_geometa_db_version', WP_GEOMETA_VERSION );
     143        update_option( 'wp_geometa_version', WP_GEOMETA_VERSION );
     144
     145        $wp_geoutil = WP_GeoUtil::get_instance();
     146        $wp_geoutil->get_capabilities( true );
    105147    }
    106148
     
    190232        foreach ( $this->meta_types as $type ) {
    191233            $show_index     = 'SHOW INDEX FROM ' . _get_meta_table( $type ) . '_geo WHERE Key_name=\'meta_val_spatial_idx\';';
    192             $add_index  = 'CREATE SPATIAL INDEX meta_val_spatial_idx ON ' . _get_meta_table( $type ) . '_geo (meta_value);'; 
    193 
    194             $found_query = $wpdb->query( $show_index );
     234            $add_index  = 'CREATE SPATIAL INDEX meta_val_spatial_idx ON ' . _get_meta_table( $type ) . '_geo (meta_value);';
     235
     236            $found_query = $wpdb->query( $show_index ); // @codingStandardsIgnoreLine
    195237            if ( $found_query === 0 ) {
    196                 $wpdb->query( $add_index );
     238                $wpdb->query( $add_index ); // @codingStandardsIgnoreLine
    197239            }
    198240        }
     
    200242        $wpdb->suppress_errors( $suppress );
    201243        $wpdb->show_errors( $errors );
    202 
    203         // These files add extra SQL support
    204         $extra_sql = array( 'first_geometry.sql', 'buffer_point.sql' , 'distance_point.sql', 'point_bearing_distance.sql' );
    205         foreach( $extra_sql as $sql_file ) {
    206             $sql_code = file_get_contents( __DIR__ . '/sql/' . $sql_file );
    207             // $sql_code = preg_replace('DELIMITER.*','',$sql_code );
    208             $sql_code = explode('$$', $sql_code);
    209             $sql_code = array_map('trim',$sql_code);
    210             $sql_code = array_filter($sql_code, function($statement){
     244    }
     245
     246    /**
     247     * Install handy extra SQL functions
     248     */
     249    public function install_extra_sql_functions() {
     250        global $wpdb;
     251
     252        $sql_files = apply_filters( 'wpgm_extra_sql_functions', array() );
     253
     254        $suppress = $wpdb->suppress_errors( true );
     255        $errors = $wpdb->show_errors( false );
     256
     257        // These files add extra SQL support.
     258        foreach ( $sql_files as $sql_file ) {
     259
     260            if ( ! is_file( $sql_file ) ) {
     261                continue;
     262            }
     263
     264            $sql_code = file_get_contents( $sql_file ); // @codingStandardsIgnoreLine
     265            $sql_code = explode( '$$', $sql_code );
     266            $sql_code = array_map( 'trim',$sql_code );
     267            $sql_code = array_filter($sql_code, function( $statement ) {
    211268                if ( empty( $statement ) ) {
    212269                    return false;
    213270                }
    214                 if ( strpos($statement, 'DELIMITER') !== FALSE ) {
     271                if ( strpos( $statement, 'DELIMITER' ) !== false ) {
    215272                    return false;
    216273                }
    217274                return true;
    218275            });
    219             foreach( $sql_code as $statement ) {
    220                 $res = $wpdb->query( $statement );
    221                 $a = 1;
    222             }
    223         }
     276            foreach ( $sql_code as $statement ) {
     277                $res = $wpdb->query( $statement ); // @codingStandardsIgnoreLine
     278            }
     279        }
     280
     281        $wpdb->suppress_errors( $suppress );
     282        $wpdb->show_errors( $errors );
    224283    }
    225284
     
    228287     */
    229288    public function uninstall() {
     289        $this->uninstall_tables();
     290        $this->uninstall_extra_sql_functions();
     291    }
     292
     293    /**
     294     * Un-create the geo tables
     295     */
     296    public function uninstall_tables() {
    230297        global $wpdb;
    231298
     
    238305        }
    239306
    240         $extra_sql = array( 'first_geometry.sql', 'buffer_point.sql' , 'distance_point.sql', 'point_bearing_distance.sql' );
    241 
    242         foreach( $extra_sql as $sql_file ) {
    243             $sql_code = file_get_contents( __DIR__ . '/sql/' . $sql_file );
    244             // $sql_code = preg_replace('DELIMITER.*','',$sql_code );
    245             $sql_code = explode('$$', $sql_code);
    246             $sql_code = array_map('trim',$sql_code);
    247             $sql_code = array_filter($sql_code, function($statement){
    248                 if ( strpos($statement, 'DROP FUNCTION') === FALSE ) {
     307        $wpdb->suppress_errors( $suppress );
     308        $wpdb->show_errors( $errors );
     309    }
     310
     311    /**
     312     * Remove the extra SQL functions
     313     */
     314    public function uninstall_extra_sql_functions() {
     315        global $wpdb;
     316
     317        $sql_files = apply_filters( 'wpgm_extra_sql_functions', array() );
     318
     319        $suppress = $wpdb->suppress_errors( true );
     320        $errors = $wpdb->show_errors( false );
     321
     322        foreach ( $sql_files as $sql_file ) {
     323
     324            if ( ! is_file( $sql_file ) ) {
     325                continue;
     326            }
     327
     328            $sql_code = file_get_contents( $sql_file ); // @codingStandardsIgnoreLine
     329            $sql_code = explode( '$$', $sql_code );
     330            $sql_code = array_map( 'trim',$sql_code );
     331            $sql_code = array_filter($sql_code, function( $statement ) {
     332                if ( strpos( $statement, 'DROP FUNCTION' ) === false ) {
    249333                    return false;
    250334                }
    251335                return true;
    252336            });
    253             foreach( $sql_code as $statement ) {
    254                 $res = $wpdb->query( $statement );
    255                 $a = 1;
     337            foreach ( $sql_code as $statement ) {
     338                $res = $wpdb->query( $statement ); // @codingStandardsIgnoreLine
    256339            }
    257340        }
     
    463546                ORDER BY $metatable.$meta_pkey
    464547                LIMIT 100";
    465                
     548
    466549                $res = $wpdb->get_results( $q,ARRAY_A ); // @codingStandardsIgnoreLine
    467550                $found_rows = count( $res );
     
    519602     * @param string $object_type Which WP type is it? (comment/user/post/term).
    520603     */
    521     public static function handle_latlng_meta( $meta_args, $object_type ) {
     604    public static function wpgm_pre_metaval_to_geom( $meta_args, $object_type ) {
    522605        $object_id = $meta_args[1];
    523606        $metakey = $meta_args[2];
     
    565648     * It gives us an opportunity to re-populate the meta table if needed.
    566649     */
    567     public function populate_latlng_geo() {
     650    public function wpgm_populate_geo_tables() {
    568651        global $wpdb;
    569652
     
    642725     * @return The array of meta IDs to delete.
    643726     */
    644     public function delete_latlng_geo( $meta_ids, $type, $object_id, $meta_key, $meta_value ) {
     727    public function wpgm_pre_delete_geometa( $meta_ids, $type, $object_id, $meta_key, $meta_value ) {
    645728        global $wpdb;
    646729
     
    673756        return $meta_ids;
    674757    }
     758
     759    /**
     760     * Callback to turn $this->extra_sql into absolute paths.
     761     *
     762     * @param array $sql_files An array of extra SQL files to load functions from.
     763     */
     764    public function wpgm_extra_sql_functions( $sql_files ) {
     765        foreach ( $this->extra_sql as $extra_sql ) {
     766            $full_path = dirname( __FILE__ ) . '/sql/' . $extra_sql;
     767            if ( ! in_array( $full_path, $sql_files, true ) ) {
     768                $sql_files[] = $full_path;
     769            }
     770        }
     771        return $sql_files;
     772    }
    675773}
  • wp-geometa/trunk/lib/wp-geometa-lib/wp-geoutil.php

    r1557784 r1607853  
    99 * @license GNU GPL v2
    1010 */
    11 
    12 defined( 'ABSPATH' ) or die( 'No direct access' );
    13 
    14 /**
    15  * Include geoPHP for this function
    16  */
    17 require_once( dirname( __FILE__ ) . '/geoPHP/geoPHP.inc' );
    1811
    1912/**
     
    234227
    235228    /**
     229     * Has plugins loaded been run yet?
     230     *
     231     * @var $plugins_loaded_run
     232     */
     233    public static $plugins_loaded_run = false;
     234
     235    /**
    236236     * The instance variable
    237237     *
     
    246246    public static function get_instance() {
    247247        if ( is_null( self::$_instance ) ) {
     248            global $wp_actions;
    248249            self::$_instance = new self;
    249             self::$geojson = new GeoJSON();
    250             self::$geowkt = new WKT();
    251250            self::$srid = 4326;
    252             add_action( 'plugins_loaded', array( 'WP_GeoUtil', 'plugins_loaded' ) );
     251
     252            if ( isset( $wp_actions['plugins_loaded'] ) ) {
     253                WP_GeoUtil::plugins_loaded();
     254            } else {
     255                add_action( 'plugins_loaded', array( 'WP_GeoUtil', 'plugins_loaded' ) );
     256            }
     257
     258            spl_autoload_register( array( 'WP_GeoUtil', 'spl_autoload_register' ) );
    253259        }
    254260
    255261        return self::$_instance;
     262    }
     263
     264    /**
     265     * Handle autoloading when looking for the geoPHP class.
     266     *
     267     * @param string $class_name The class name that PHP is looking for.
     268     */
     269    public static function spl_autoload_register( $class_name ) {
     270        if ( in_array( $class_name, array( 'WKT', 'GeoJSON' ), true ) ) {
     271            /**
     272            * Include geoPHP for this function
     273            */
     274            require_once( dirname( __FILE__ ) . '/geoPHP/geoPHP.inc' );
     275        }
    256276    }
    257277
     
    261281     */
    262282    public static function plugins_loaded() {
    263         WP_GeoUtil::$srid = apply_filters( 'wp_geoquery_srid', 4326 );
    264 
    265         $orig_funcs = array_map('strtolower',WP_GeoUtil::$all_funcs);
    266         WP_GeoUtil::$all_funcs = apply_filters( 'wpgq_known_capabilities', WP_GeoUtil::$all_funcs);
    267         $new_funcs = array_map('strtolower',WP_GeoUtil::$all_funcs);
     283
     284        WP_GeoUtil::$srid = apply_filters( 'wpgm_geoquery_srid', 4326 );
     285
     286        /* This filter has been deprecated and will be removed in a future version. */
     287        WP_GeoUtil::$srid = apply_filters( 'wp_geoquery_srid', WP_GeoUtil::$srid );
     288
     289        $orig_funcs = array_map( 'strtolower',WP_GeoUtil::$all_funcs );
     290
     291        WP_GeoUtil::get_all_funcs();
     292
     293        WP_GeoUtil::$plugins_loaded_run = true;
     294
     295        $new_funcs = array_map( 'strtolower',WP_GeoUtil::$all_funcs );
     296
    268297        $diff = array_diff( $new_funcs, $orig_funcs );
    269298        if ( count( $diff ) > 0 ) {
    270299            WP_GeoUtil::get_capabilities( true, false );
    271300        }
     301    }
     302
     303    /**
     304     * This function loads all known functions, including applying filters to load from other plugins.
     305     */
     306    public static function get_all_funcs() {
     307        WP_GeoUtil::$all_funcs = apply_filters( 'wpgm_known_capabilities', WP_GeoUtil::$all_funcs );
     308
     309        /* This filter has been deprecated and will be removed in a future version. */
     310        WP_GeoUtil::$all_funcs = apply_filters( 'wpgq_known_capabilities', WP_GeoUtil::$all_funcs );
     311
     312        WP_GeoUtil::$all_funcs = array_unique( WP_GeoUtil::$all_funcs );
     313
     314        return WP_GeoUtil::$all_funcs;
    272315    }
    273316
     
    337380     *
    338381     * @param anything $metaval The value to turn into GeoJSON.
    339      * @param string $return_type The supported types are 'string' and 'array'.
     382     * @param string   $return_type The supported types are 'string' and 'array'.
    340383     */
    341384    public static function metaval_to_geojson( $metaval, $return_type = 'string' ) {
    342 
    343         // Quick exit
    344         if ( empty( $metaval) ) {
    345             return false;
    346         }
    347 
    348         // Could be a serialized array
    349385        $metaval = maybe_unserialize( $metaval );
    350386
    351         // If we've been asked for a string and it's a GeoJSON string,
    352         // we can just return now.
    353         if ( self::is_geojson( $metaval, ( 'string' === $return_type ) ) ) {
     387        if ( self::is_geojson( $metaval ) ) {
    354388            return $metaval;
     389        }
     390
     391        if ( empty( $metaval ) ) {
     392            return false;
     393        }
     394
     395        // Exit early if we're a non-GeoJSON string.
     396        if ( is_string( $metaval ) ) {
     397            if ( strpos( $metaval,'{' ) === false || strpos( $metaval,'Feature' ) === false || strpos( $metaval,'geometry' ) === false ) {
     398                return false;
     399            } else {
     400                $metaval = json_decode( $metaval,true );
     401            }
    355402        }
    356403
     
    363410        $string_metaval = wp_json_encode( $metaval );
    364411
    365         if ( !self::is_geojson( $string_metaval, 'true' ) ) {
     412        if ( ! self::is_geojson( $metaval ) ) {
    366413            return false;
    367414        }
     
    378425     *
    379426     * @param mixed $metaval The meta value to try to convert to WKT.
    380      * @param bool $force_multi Should the value be turned into a MULTI type geometry? Default is false. This is set to true by WP-GeoMeta before storing values in the database.
     427     * @param bool  $force_multi Should the value be turned into a MULTI type geometry? Default is false. This is set to true by WP-GeoMeta before storing values in the database.
    381428     *
    382429     * @return A WKT geometry string.
    383430     */
    384     public static function metaval_to_geom( $metaval = false, $force_multi = false) {
    385 
    386         $maybe_geom = apply_filters( 'wpgq_metaval_to_geom', $metaval );
     431    public static function metaval_to_geom( $metaval = false, $force_multi = false ) {
     432
     433        $maybe_geom = apply_filters( 'wpgm_metaval_to_geom', $metaval );
     434
     435        /* This filter has been deprecated and will be removed in a future version. */
     436        $maybe_geom = apply_filters( 'wpgq_metaval_to_geom', $maybe_geom );
     437
    387438        if ( self::is_geom( $maybe_geom ) ) {
    388439            return $maybe_geom;
    389440        }
    390441
    391         // Everything becomes GeoJSON so that the rest of this function will be simpler
    392         $metaval = self::metaval_to_geojson( $metaval, 'string' );
    393 
    394         if ( $metaval === false ) {
     442        // Everything becomes GeoJSON so that the rest of this function will be simpler.
     443        $make_string = ( $force_multi ? 'string' : 'array' );
     444        $metaval = self::metaval_to_geojson( $metaval, $make_string );
     445
     446        if ( false === $metaval ) {
    395447            return $metaval;
    396448        }
    397        
     449
    398450        if ( $force_multi ) {
    399451            $metaval = self::merge_geojson( $metaval );
     
    404456        }
    405457
     458        // Stringify any arrays.
     459        if ( is_array( $metaval ) ) {
     460            $metaval = wp_json_encode( $metaval );
     461        }
     462
    406463        // Convert GeoJSON to WKT.
    407464        try {
    408             $geom = self::$geojson->read( (string) $metaval );
     465            $geom = self::get_geojson()->read( (string) $metaval );
    409466            if ( is_null( $geom ) ) {
    410467                return false;
     
    415472
    416473        try {
    417             $wkt = self::$geowkt->write( $geom );
     474            $wkt = self::get_wkt()->write( $geom );
    418475
    419476            /*
     
    443500     */
    444501    public static function geom_to_geojson( $wkt ) {
    445         $maybe_geojson = apply_filters( 'wpgq_geom_to_geojson', $wkt );
     502        $maybe_geojson = apply_filters( 'wpgm_geom_to_geojson', $wkt );
     503
     504        /* This filter has been deprecated and will be removed in a future version. */
     505        $maybe_geojson = apply_filters( 'wpgq_geom_to_geojson', $maybe_geojson );
    446506        if ( self::is_geojson( $maybe_geojson ) ) {
    447507            return $maybe_geojson;
     
    460520            stripos( $maybe_geojson, 'MULTIPOINT' ) !== 0 &&
    461521            stripos( $maybe_geojson, 'MULTILINESTRING' ) !== 0 &&
    462             stripos( $maybe_geojson, 'MULTIPOLYGON' ) !== 0
     522            stripos( $maybe_geojson, 'MULTIPOLYGON' ) !== 0 &&
     523            stripos( $maybe_geojson, 'GEOMETRYCOLLECTION' ) !== 0
    463524        ) {
    464525            return false;
     
    466527
    467528        try {
    468             $geom = self::$geowkt->read( $maybe_geojson );
    469             $geojson = self::$geojson->write( $geom );
    470             if ( strpos( $maybe_geojson, '{' ) === false || strpos( $maybe_geojson, 'Feature' ) === false || strpos( $maybe_geojson, 'geometry' ) === false ) {
     529            $geom = self::get_wkt()->read( $maybe_geojson );
     530            $geojson = self::get_geojson()->write( $geom );
     531
     532            // Do we need to wrap it?
     533            if ( ! empty( $geojson ) && strpos( $geojson, '"type":"Feature"' ) === false ) {
    471534                $geojson = '{"type":"Feature","geometry":' . $geojson . ',"properties":{}}';
    472535            }
     536
    473537            return $geojson;
    474538        } catch ( Exception $e ) {
     
    490554            }
    491555
    492             $what = self::$geowkt->read( (string) $maybe_geom );
     556            if ( stripos( $maybe_geom, 'POINT' ) !== 0 &&
     557                stripos( $maybe_geom, 'LINESTRING' ) !== 0 &&
     558                stripos( $maybe_geom, 'POLYGON' ) !== 0 &&
     559                stripos( $maybe_geom, 'MULTIPOINT' ) !== 0 &&
     560                stripos( $maybe_geom, 'MULTILINESTRING' ) !== 0 &&
     561                stripos( $maybe_geom, 'MULTIPOLYGON' ) !== 0 &&
     562                stripos( $maybe_geom, 'GEOMETRYCOLLECTION' ) !== 0
     563            ) {
     564                return false;
     565            }
     566
     567            $what = self::get_wkt()->read( (string) $maybe_geom );
    493568            if ( null !== $what ) {
    494569                return true;
     
    505580     *
    506581     * @param anything $maybe_geojson Check if a value is GeoJSON or not.
    507      * @param bool $string_only Should GeoJSON compatible strings and objects be counted as GeoJSON? Default is false (allow arrays/objects).
     582     * @param bool     $string_only Should GeoJSON compatible strings and objects be counted as GeoJSON? Default is false (allow arrays/objects).
    508583     *
    509584     * @return boolean
     
    512587        try {
    513588
    514             if ( !is_string( $maybe_geojson ) && $string_only ) {
     589            if ( ! is_string( $maybe_geojson ) && $string_only ) {
    515590                return false;
    516591            }
    517592
    518593            if ( is_array( $maybe_geojson ) || is_object( $maybe_geojson ) ) {
    519                 $maybe_geojson = json_encode( $maybe_geojson );
    520             }
     594                $maybe_geojson = wp_json_encode( $maybe_geojson );
     595            }
     596
     597            $maybe_geojson = (string) $maybe_geojson;
    521598
    522599            if ( strpos( $maybe_geojson, '{' ) === false || strpos( $maybe_geojson, 'Feature' ) === false || strpos( $maybe_geojson, 'geometry' ) === false ) {
    523600                return false;
    524             }
    525 
    526             $what = self::$geojson->read( (string) $maybe_geojson );
    527 
     601            }
     602
     603            $what = self::get_geojson()->read( $maybe_geojson );
    528604            if ( null !== $what ) {
    529605                return true;
     
    546622     * @param bool $retest Should we re-check and re-store our capabilities.
    547623     * @param bool $lower Should all functions be lower-cased before returning.
    548      */
    549     public static function get_capabilities( $retest = false, $lower = true ) {
     624     * @param bool $cache_results Should our known functions be cached once they're generated.
     625     */
     626    public static function get_capabilities( $retest = false, $lower = true, $cache_results = true ) {
    550627        global $wpdb;
     628
     629        if ( true !== WP_GeoUtil::$plugins_loaded_run ) {
     630            WP_GeoUtil::plugins_loaded();
     631        }
    551632
    552633        if ( ! $retest ) {
     
    572653        foreach ( WP_GeoUtil::$all_funcs as $func ) {
    573654
    574             // First, check to see if a custom function exists
     655            // First, check to see if a custom function exists.
    575656            $q = "SELECT IF( COUNT(*) = 0, 'F' , 'T' ) AS ProcedureExists FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA = '{$wpdb->dbname}' AND ROUTINE_TYPE = 'FUNCTION' AND UCASE(ROUTINE_NAME) = UCASE('$func');";
    576             $custom_func = $wpdb->get_var( $q );
     657            $custom_func = $wpdb->get_var( $q ); // @codingStandardsIgnoreLine
    577658
    578659            if ( 'T' === $custom_func ) {
     
    581662            }
    582663
    583             // Otherwise check if it's a built-in
     664            // Otherwise check if it's a built-in.
    584665            $q = "SELECT $func() AS worked";
    585666            $wpdb->query( $q ); // @codingStandardsIgnoreLine
     
    594675        $wpdb->show_errors( $errors );
    595676
    596         update_option( 'wp_geometa_capabilities',self::$found_funcs, false );
    597 
    598         return self::get_capabilities( false, $lower );
     677        if ( $cache_results ) {
     678            update_option( 'wp_geometa_capabilities',self::$found_funcs, false );
     679        }
     680
     681        return self::get_capabilities( false, $lower, $cache_results );
    599682    }
    600683
     
    607690
    608691    /**
    609      * Support calling any geometry function.
    610      *
    611      * eg.
    612      * WP_GeoUtil::Buffer( $geometry, $distance);
     692     * Static magic method to support calling any geometry function.
     693     *
     694     * Eg. WP_GeoUtil::Buffer( $geometry, $distance);
     695     *
     696     * @param string $name The name of the function that is being called.
     697     * @param array  $arguments The arguments for the function.
    613698     */
    614699    public static function __callStatic( $name, $arguments ) {
    615         if ( in_array( strtolower( $name ), self::get_capabilities() ) ) {
     700        if ( in_array( strtolower( $name ), self::get_capabilities(), true ) ) {
    616701            return self::run_spatial_query( $name, $arguments );
    617702        }
     
    619704
    620705    /**
    621      * Run the actual spatial query
    622      *
    623      * Any geometries should be GeoJSON compatible
    624      *
    625      * Geometry responses will be returned as GeoJSON
    626      *
    627      * Other responses will be returned as is
     706     * Run the actual spatial query.
     707     *
     708     * Any geometries should be GeoJSON compatible.
     709     *
     710     * Geometry responses will be returned as GeoJSON.
     711     *
     712     * Other responses will be returned as is.
     713     *
     714     * @param string $name The name of the function that is being called.
     715     * @param array  $arguments The arguments for the function.
    628716     */
    629717    private static function run_spatial_query( $name, $arguments = array() ) {
    630718        global $wpdb;
    631719
    632         if ( empty($arguments ) ) {
     720        if ( empty( $arguments ) ) {
    633721            return false;
    634722        }
    635723
    636724        $q = 'SELECT ' . $name . '(';
    637         foreach( $arguments as $idx => $arg ) {
     725        foreach ( $arguments as $idx => $arg ) {
    638726
    639727            if ( $idx > 0 ) {
     
    642730
    643731            $maybe_geom = self::metaval_to_geom( $arg );
    644             if ( $maybe_geom !== false ) {
    645                 $arguments[$idx] = $maybe_geom;
     732            if ( false !== $maybe_geom ) {
     733                $arguments[ $idx ] = $maybe_geom;
    646734                $q .= 'GeomCollFromText(%s)';
    647735            } else {
     
    651739        $q .= ')';
    652740
    653         $real_q = 'SELECT IF( GeometryType( retval ) IS NULL, retval, AsText( retval ) ) AS res FROM ( ' . $q . ' AS retval ) rq';
    654 
    655         $sql = $wpdb->prepare( $real_q, $arguments );
    656 
    657         $res = $wpdb->get_var( $sql );
     741        /*
     742        -- Detect geometry.
     743        -- Data is WKB, with a 4 byte leading SRID (which may be 00 00 00 00)
     744        -- In big endian it will look like this:
     745        -- E6 10    00          00 01 02 00
     746        -- srid    endianness   WKB integer code
     747
     748        -- In little endian it should look like this:
     749        -- 10 E6        01      01 00 00 02
     750        -- srid    endianness   WKB integer code
     751        -- Note: MySQL appears to use the Z codes, though I can't find actual support for Z values
     752        */
     753
     754        $real_q = 'SELECT IF(
     755            COALESCE( SUBSTR(HEX(retval),5,10) IN (
     756
     757                -- big endian
     758                \'0000010000\', -- geometry
     759                \'0000010100\', -- point
     760                \'0000010200\', -- line
     761                \'0000010300\', -- polygon
     762                \'0000010400\', -- multipoint
     763                \'0000010500\', -- multiline
     764                \'0000010600\', -- multipolygon
     765
     766                -- little endian
     767                \'0001000000\', -- geometry
     768                \'0001000001\', -- point
     769                \'0001000002\', -- line
     770                \'0001000003\', -- polygon
     771                \'0001000004\', -- multipoint
     772                \'0001000005\', -- multiline
     773                \'0001000006\' -- multipolygon
     774            ), false) , AsText( retval ), retval ) AS res FROM ( ' . $q . ' AS retval ) rq';
     775
     776        $sql = $wpdb->prepare( $real_q, $arguments ); // @codingStandardsIgnoreLine
     777
     778        $res = $wpdb->get_var( $sql ); // @codingStandardsIgnoreLine
    658779
    659780        $maybe_geojson = self::geom_to_geojson( $res );
    660         if ( $maybe_geojson !== false ) {
     781        if ( false !== $maybe_geojson ) {
    661782            return $maybe_geojson;
    662         } 
     783        }
    663784
    664785        return $res;
    665786    }
     787
     788    /**
     789     * Get the GeoJSON object, creating it if needed.
     790     */
     791    private static function get_geojson() {
     792        if ( ! isset( self::$geojson ) ) {
     793            self::$geojson = new GeoJSON();
     794        }
     795
     796        return self::$geojson;
     797    }
     798
     799    /**
     800     * Get the WKT object, creating it if needed.
     801     */
     802    private static function get_wkt() {
     803        if ( ! isset( self::$geowkt ) ) {
     804            self::$geowkt = new WKT();
     805        }
     806        return self::$geowkt;
     807    }
    666808}
    667 
    668 WP_GeoUtil::get_instance();
  • wp-geometa/trunk/readme.txt

    r1557784 r1607853  
    11=== WP-GeoMeta ===
    2 Contributors: stuporglue, cimburacom
    3 Donate link: https://cimbura.com/contact-us/make-a-payment/
    4 Tags: GIS, spatial, mysql, mariadb, geography, mapping, meta, metadata
     2Contributors: stuporglue, luminfire
     3Donate link: https://LuminFire.com/contact-us/make-a-payment/
     4Tags: GIS, geo, spatial, mysql, mariadb, geography, mapping, meta, metadata
    55Requires at least: 4.4.0
    6 Tested up to: 4.7.0
    7 Stable tag: trunk
     6Tested up to: 4.7.2
     7Stable tag: 0.3.2
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5050For community support try [WherePress.com](http://WherePress.com/), or [The Spatial Community](https://julien24.typeform.com/to/kGPqYr).
    5151
    52 For commercial support you can contact the plugin developer at [Cimbura.com](https://cimbura.com/contact-us/project-request-form/)
     52For commercial support you can contact the plugin developer at
     53[LuminFire.com](https://LuminFire.com/contact-us/project-request-form/)
    5354
    5455For fast and short questions you can [contact me](https://twitter.com/stuporglue) on twitter
     
    130131== Upgrade Notice ==
    131132
     133= 0.3.2 =
     134 * Update to wp-geometa-lib 0.3.2.
     135 * Updated internal filter callback function names to match the filter they're for.
     136 * Updated branding to reflect company name change.
     137 * Updated handling if submodules aren't checked out.
     138
    132139= 0.3.1 =
    133140* This release brings support for stored spatial functions, a new button to
  • wp-geometa/trunk/wp-geometa.php

    r1557784 r1607853  
    1111 * Description: Store and search spatial metadata while taking advantage of MySQL spatial types and indexes.
    1212 * Author: Michael Moore
    13  * Author URI: http://cimbura.com
    14  * Version: 0.3.1
     13 * Author URI: http://LuminFire.com
     14 * Version: 0.3.2
    1515 * Text Domain: wp-geometa
    1616 * Domain Path: /lang
     
    1919 */
    2020
    21 
    22 
    2321/**
    2422 * Always include wp-geometa-lib so that it's available for others to use
    2523 */
    26 require_once( dirname( __FILE__ ) . '/lib/wp-geometa-lib/wp-geometa-lib-loader.php' );
     24$wp_geometa_lib_loader = dirname( __FILE__ ) . '/lib/wp-geometa-lib/wp-geometa-lib-loader.php';
     25
     26if ( file_exists( $wp_geometa_lib_loader ) ) {
     27    require_once( $wp_geometa_lib_loader );
     28    register_activation_hook( __FILE__ , array('WP_GeoMeta','install'));
     29} else {
     30    error_log( __( "Could not load wp-geometa-lib. You probably cloned wp-geometa from git and didn't check out submodules!", 'wp-geometa' ) );
     31
     32    if ( is_admin() ) {
     33        print esc_html__( "Could not load wp-geometa-lib. You probably cloned wp-geometa from git and didn't check out submodules!", 'wp-geometa' );
     34    }
     35}
    2736
    2837/**
     
    3140if ( is_admin() ) {
    3241    require_once( dirname( __FILE__ ) . '/lib/wp-geometa-dash.php' );
     42
     43    $leaflet_php_loader = dirname( __FILE__ ) . '/lib/leaflet-php/leaflet-php-loader.php';
     44
     45    if ( file_exists( $leaflet_php_loader ) ) {
     46        require_once( $leaflet_php_loader );
     47    } else {
     48        error_log( __( "Could not load leaflet-php-loader. You probably cloned wp-geometa from git and didn't check out submodules!", 'wp-geometa' ) );
     49        print esc_html__( "Could not load leaflet-php-loader. You probably cloned wp-geometa from git and didn't check out submodules!", 'wp-geometa' );
     50    }
     51
    3352    WP_GeoMeta_Dash::get_instance();
    3453
Note: See TracChangeset for help on using the changeset viewer.