qr code generator c# Lesson 1: Implementing Spatial Data Types in Visual C#.NET

Paint QR Code 2d barcode in Visual C#.NET Lesson 1: Implementing Spatial Data Types

Lesson 1: Implementing Spatial Data Types
QR Code 2d Barcode Maker In C#
Using Barcode creator for VS .NET Control to generate, create QR Code ISO/IEC18004 image in .NET framework applications.
www.OnBarcode.com
Denso QR Bar Code Scanner In C#
Using Barcode scanner for .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
The Parse extended static geography method returns a geography instance when the input is expressed in the OGC WKT representation. The Parse method has a single input parameter that defines the WKT representation of the geometry instance to be returned.
Creating Barcode In Visual C#
Using Barcode encoder for VS .NET Control to generate, create bar code image in .NET framework applications.
www.OnBarcode.com
Bar Code Scanner In Visual C#
Using Barcode recognizer for VS .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
More info
Generating QR Code JIS X 0510 In .NET Framework
Using Barcode creator for ASP.NET Control to generate, create Denso QR Bar Code image in ASP.NET applications.
www.OnBarcode.com
Create QR Code In .NET Framework
Using Barcode creation for .NET Control to generate, create Quick Response Code image in .NET framework applications.
www.OnBarcode.com
SPatiaL MetHODS
Generate Quick Response Code In Visual Basic .NET
Using Barcode printer for .NET Control to generate, create QR Code image in .NET applications.
www.OnBarcode.com
Barcode Generation In Visual C#.NET
Using Barcode generator for VS .NET Control to generate, create bar code image in .NET framework applications.
www.OnBarcode.com
For more information about the spatial methods available in SQL Server 2008, see geography Data Type Method Reference and geometry Data Type Method Reference in SQL Server Books Online.
Data Matrix 2d Barcode Maker In Visual C#.NET
Using Barcode creator for .NET framework Control to generate, create Data Matrix 2d barcode image in VS .NET applications.
www.OnBarcode.com
Print Code 128 Code Set B In C#.NET
Using Barcode encoder for VS .NET Control to generate, create Code 128 image in .NET framework applications.
www.OnBarcode.com
The following code adds a row for the COSI museum in Columbus, Ohio, to the Museum table. This code uses the Parse and Point methods to create an instance of a point based on a WKT description. The default SRID of 4326 is used:
Draw Matrix Barcode In Visual C#
Using Barcode generator for .NET Control to generate, create Matrix Barcode image in Visual Studio .NET applications.
www.OnBarcode.com
Identcode Drawer In C#
Using Barcode creator for Visual Studio .NET Control to generate, create Identcode image in .NET framework applications.
www.OnBarcode.com
INSERT INTO Museum (MuseumName, MuseumAddress, Location) VALUES ('COSI Columbus', '333 West Broad Street, Columbus, OH 43215', geography::Parse('POINT(-83.0086 39.95954)'));
Barcode Encoder In Visual Basic .NET
Using Barcode generator for VS .NET Control to generate, create barcode image in Visual Studio .NET applications.
www.OnBarcode.com
GTIN - 128 Creator In Objective-C
Using Barcode creator for iPhone Control to generate, create EAN / UCC - 14 image in iPhone applications.
www.OnBarcode.com
note
Printing Code 3/9 In VB.NET
Using Barcode creation for .NET framework Control to generate, create Code 3 of 9 image in VS .NET applications.
www.OnBarcode.com
Generate Bar Code In Visual Studio .NET
Using Barcode generator for Reporting Service Control to generate, create barcode image in Reporting Service applications.
www.OnBarcode.com
PARSE anD STGEOMFROMTEXT
UCC - 12 Printer In Java
Using Barcode generation for Android Control to generate, create UCC - 12 image in Android applications.
www.OnBarcode.com
Code 39 Scanner In Java
Using Barcode scanner for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Both the Parse and STGeomFromText methods return a geometry instance from an OGC WKT representation. The difference between the commands is that Parse assumes an SRID of 0 as a parameter. STGeomFromText includes an argument to specify the SRID.
UCC-128 Reader In VB.NET
Using Barcode decoder for .NET framework Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
Encoding EAN13 In None
Using Barcode creator for Word Control to generate, create UPC - 13 image in Word applications.
www.OnBarcode.com
Figure 8-2 shows a SELECT command and result set displaying the text output for the COSI museum row entered previously.
FiGURe 8-2 A geography point displayed as text
The ToString function displays the geography value as readable text in the same WKT representation that you used when you added the row. Figure 8-3 shows location information without converting the location to a string for readability. Notice in Figure 8-3, that an additional tab named Spatial Results appears next to the Results tab. This tab can be used to view a graphical representation of your spatial data.
328 CHAPTER 8 Extending Microsoft SQL Server Functionality with the Spatial, Full-Text Search, and Service Broker
FiGURe 8-3 A geography point returned as a hexadecimal value, which is difficult to read
Before creating Figure 8-4, a new row for the Columbus Art Museum is added to the table. You can use the following code to add the second row to the Museum table:
INSERT INTO Museum (MuseumName, MuseumAddress, Location) VALUES ('Columbus Art Museum', '480 East Broad Street, Columbus, OH 43215', geography::Parse('POINT(-82.98775 39.963775)'));
Figure 8-4 represents two points of data in the museum table. Unfortunately, it is difficult to see these individual points in the screen capture. A description of the point appears when you place the pointer over the location, as shown in Figure 8-4.
Point for the Columbus Art Museum is in the middle of the circle
FiGURe 8-4 Sample of two points in the Spatial Results tab
Lesson 1: Implementing Spatial Data Types
To better demonstrate the Spatial Results tab, you can create a line using the STLineFromText and LINESTRING methods. The following code defines a geography type variable and sets the variable to a line between two points. Figure 8-5 shows the line displayed in the Spatial Results tab.
FiGURe 8-5 Example of the LINESTRING method
More info
SQL SeRveR SPatiaL Data
For more information about working with spatial data in SQL Server 2008, see Spatial Ed at http://blogs.msdn.com/edkatibah/.
Pr actice
instantiating Spatial Data types
In this practice, you create a new table named Airports to store location data for airports used by customers of your travel agency. You then use several methods to add the geodetic coordinates for each location. You also create a Sales table to track the sales regions in which your travel agents are assigned customers. You use the Spatial Results tab in SSMS to view a sales region.
e xercise 1
Work with Points
In this exercise, you instantiate spatial data points and use the Spatial Results tab to view the points that you entered.
1. 2.
Start SSMS (if it s not already started), connect to the appropriate SQL Server instance, and open a new query window. In the new query window, type and execute the following command to create a new database for your travel agency:
CREATE DATABASE Travel; GO
Extending Microsoft SQL Server Functionality with the Spatial, Full-Text Search, and Service Broker
Below the existing text, type, highlight, and execute the following code to create the Airports and Sales tables:
USE Travel;
CREATE TABLE Airports (AirportID int IDENTITY PRIMARY KEY , AirportName nchar(50) , AirportCode nchar(3) , Location geography);
CREATE TABLE Sales (SalesPersonID int IDENTITY PRIMARY KEY , FirstName nchar(50) , LastName nchar(50) , SalesRegionName Nchar(50) , SalesRegionDesc nvarchar(200) , SalesRegion geography);
Below the existing text, type, highlight, and execute the following code to add rows for the Los Angeles International Airport (LAX) and London Heathrow Airport (LHR) to the Airports table:
INSERT INTO Airports (AirportName, AirportCode, Location) VALUES ('Los Angeles International Airport' , 'LAX' , geography::STGeomFromText('POINT( -118.4071611 33.9425222)', 4326));
INSERT INTO Airports (AirportName, AirportCode, Location) VALUES ('London Heathrow Airport' , 'LHR' , geography::Parse('POINT(-0.45277777 51.47138888)'));
Practice using various methods to add rows for the remaining airports in the Airport.xls file, which you can find in the 08\Lesson 1 folder in the samples installed from the companion CD. Below the existing text, type, highlight, and execute the following command to view the data that you have entered into the Airports table:
SELECT * FROM Airports;
Switch to the Spatial Results tab. Place the pointer over each of the dots representing the airports to view their properties. If necessary, use WHERE clauses to limit the result set to make it easier to read. Leave SSMS open for the next exercise.
Copyright © OnBarcode.com . All rights reserved.