-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d1dc811
Showing
15 changed files
with
467 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/data/codepointopen/*.csv | ||
.DS_Store | ||
/vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Copyright (c) 2014-2016, JMB Technology Ltd | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
Redistributions in binary form must reproduce the above copyright notice, this | ||
list of conditions and the following disclaimer in the documentation and/or | ||
other materials provided with the distribution. | ||
|
||
Neither the name of JMB Technology Ltd nor any of their products (including | ||
but not limited to OpenACalendar, HasACalendar and OpenTechCalendar) nor the | ||
names of any contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# OSData | ||
|
||
An PHP Library for working with Ordnance Survey Open Data | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
require __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src-bin'.DIRECTORY_SEPARATOR.'bootstrap.php'; | ||
|
||
|
||
/** | ||
* | ||
* @link https://github.com/JMB-Technology-Limited/OSData | ||
* @license https://raw.github.com/JMB-Technology-Limited/OSData/master/LICENSE.md 3-clause BSD | ||
* @copyright (c) JMB Technology Limited, http://jmbtechnology.co.uk/ | ||
*/ | ||
|
||
$dir = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'codepointopen'.DIRECTORY_SEPARATOR; | ||
|
||
$dataAdaptor = new \JMBTechnologyLimited\OSData\CodePointOpen\FileDataAdaptor($dir); | ||
|
||
$service = new \JMBTechnologyLimited\OSData\CodePointOpen\CodePointOpenService($dataAdaptor); | ||
|
||
$postCode = $service->getPostcode($argv[1]); | ||
|
||
if ($postCode) { | ||
print "Lat,Lng: ". $postCode->getLat().",".$postCode->getLng()."\n"; | ||
} else { | ||
print "Not Found\n"; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
require __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src-bin'.DIRECTORY_SEPARATOR.'bootstrap.php'; | ||
|
||
|
||
/** | ||
* | ||
* @link https://github.com/JMB-Technology-Limited/OSData | ||
* @license https://raw.github.com/JMB-Technology-Limited/OSData/master/LICENSE.md 3-clause BSD | ||
* @copyright (c) JMB Technology Limited, http://jmbtechnology.co.uk/ | ||
*/ | ||
|
||
|
||
$inDir = $argv[1]; | ||
|
||
$outDir = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'codepointopen'.DIRECTORY_SEPARATOR; | ||
|
||
$dataAdaptor = new \JMBTechnologyLimited\OSData\CodePointOpen\FileDataAdaptor($outDir); | ||
|
||
$service = new \JMBTechnologyLimited\OSData\CodePointOpen\CodePointOpenService($dataAdaptor); | ||
|
||
$service->loadData($inDir); | ||
|
||
print "Done"; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "jmbtechnologylimited/osdata", | ||
"type": "library", | ||
"description": "for working with Ordnance Survey Open Data", | ||
"keywords": [], | ||
"homepage": "https://github.com/JMB-Technology-Limited/OSData", | ||
"license": "BSD", | ||
"authors": [ ], | ||
"require": { | ||
"php": ">=5.3.0", | ||
"jmbtechnologylimited/osmaths": "1.0.*" | ||
}, | ||
"autoload": { | ||
"psr-0": { | ||
"JMBTechnologyLimited": "src" | ||
} | ||
}, | ||
"require-dev": { | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
require __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php'; | ||
|
||
/** | ||
* | ||
* @link https://github.com/JMB-Technology-Limited/OSData | ||
* @license https://raw.github.com/JMB-Technology-Limited/OSData/master/LICENSE.md 3-clause BSD | ||
* @copyright (c) JMB Technology Limited, http://jmbtechnology.co.uk/ | ||
*/ | ||
|
||
function autoload($class) { | ||
$f = __DIR__. DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR. | ||
'src'.DIRECTORY_SEPARATOR.str_replace("\\", DIRECTORY_SEPARATOR, $class).'.php'; | ||
if (file_exists($f)) { | ||
require_once $f; | ||
return; | ||
} | ||
} | ||
spl_autoload_register('autoload'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace JMBTechnologyLimited\OSData; | ||
|
||
/** | ||
* | ||
* @link https://github.com/JMB-Technology-Limited/OSData | ||
* @license https://raw.github.com/JMB-Technology-Limited/OSData/master/LICENSE.md 3-clause BSD | ||
* @copyright (c) JMB Technology Limited, http://jmbtechnology.co.uk/ | ||
*/ | ||
|
||
abstract class BaseDataAdaptor { | ||
|
||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace JMBTechnologyLimited\OSData; | ||
|
||
|
||
/** | ||
* | ||
* @link https://github.com/JMB-Technology-Limited/OSData | ||
* @license https://raw.github.com/JMB-Technology-Limited/OSData/master/LICENSE.md 3-clause BSD | ||
* @copyright (c) JMB Technology Limited, http://jmbtechnology.co.uk/ | ||
*/ | ||
|
||
abstract class BaseDataService { | ||
|
||
|
||
|
||
|
||
/** | ||
* @return boolean Was this successful? | ||
*/ | ||
abstract public function openConnection(); | ||
|
||
abstract public function closeConnection(); | ||
|
||
abstract public function loadData($sourceDir); | ||
|
||
|
||
|
||
} |
58 changes: 58 additions & 0 deletions
58
src/JMBTechnologyLimited/OSData/CodePointOpen/CodePointOpenService.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
|
||
namespace JMBTechnologyLimited\OSData\CodePointOpen; | ||
|
||
|
||
use JMBTechnologyLimited\OSData\BaseDataService; | ||
|
||
/** | ||
* | ||
* @link https://github.com/JMB-Technology-Limited/OSData | ||
* @license https://raw.github.com/JMB-Technology-Limited/OSData/master/LICENSE.md 3-clause BSD | ||
* @copyright (c) JMB Technology Limited, http://jmbtechnology.co.uk/ | ||
*/ | ||
|
||
class CodePointOpenService extends BaseDataService { | ||
|
||
|
||
/** @var InterfaceDataAdaptor */ | ||
protected $dataAdaptor; | ||
|
||
/** | ||
* CodePointOpenService constructor. | ||
* | ||
*@param InterfaceDataAdaptor $dataAdaptor | ||
*/ | ||
public function __construct( InterfaceDataAdaptor $dataAdaptor) | ||
{ | ||
$this->dataAdaptor = $dataAdaptor; | ||
} | ||
|
||
|
||
/** | ||
* @return boolean Was this successful? | ||
*/ | ||
public function openConnection() | ||
{ | ||
|
||
} | ||
|
||
public function closeConnection() | ||
{ | ||
|
||
} | ||
|
||
public function loadData($sourceDir) | ||
{ | ||
$this->dataAdaptor->loadData($sourceDir); | ||
} | ||
|
||
/** @return PostCodeData */ | ||
public function getPostcode($postcode) | ||
{ | ||
return $this->dataAdaptor->getPostcode($postcode); | ||
} | ||
|
||
} | ||
|
Oops, something went wrong.