Mercurial > postarc
changeset 0:1aca3d413885 tip
Initial import of Postarc
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GPL.txt Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LGPL.txt Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Config.esriaddinx Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,29 @@ +<ESRI.Configuration xmlns="http://schemas.esri.com/Desktop/AddIns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <Name>Postarc</Name> + <AddInID>{1d7944ae-1320-4073-b318-c16e1f9b0135}</AddInID> + <Description>Add-in that can work with PostGIS geometry feature tables</Description> + <Version>1.0</Version> + <Image>Images\Postarc.png</Image> + <Author>Christian Lins</Author> + <Company>Intevation GmbH</Company> + <Date>13.08.2012</Date> + <Targets> + <Target name="Desktop" version="10.0" /> + </Targets> + <AddIn language="CLR" library="Postarc.dll" namespace="Postarc.GUI"> + <ArcMap> + <Commands> + <Button id="Intevation_GmbH_Postarc_Button1" + class="ButtonExportToPostGIS" + message="Export feature layer to PostGIS" + caption="Export feature layer to PostGIS" tip="Export feature layer to PostGIS" + category="PostGIS" image="Images\Button1.png" /> + <Button id="Intevation_GmbH_Postarc_Button2" + class="ButtonNewPostGISLayer" + message="Add an empty feature layer backed by PostGIS" + caption="Add an empty feature layer backed by PostGIS" + category="PostGIS" image="Images\ButtonNewPostGISLayer_16.png"/> + </Commands> + </ArcMap> + </AddIn> +</ESRI.Configuration> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc.csproj Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,228 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.21022</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{C9F8C93D-2614-4675-9897-2BD9ACBC32D7}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Postarc</RootNamespace> + <AssemblyName>Postarc</AssemblyName> + <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <FileUpgradeFlags> + </FileUpgradeFlags> + <OldToolsVersion>3.5</OldToolsVersion> + <UpgradeBackupLocation /> + <PublishUrl>publish\</PublishUrl> + <Install>true</Install> + <InstallFrom>Disk</InstallFrom> + <UpdateEnabled>false</UpdateEnabled> + <UpdateMode>Foreground</UpdateMode> + <UpdateInterval>7</UpdateInterval> + <UpdateIntervalUnits>Days</UpdateIntervalUnits> + <UpdatePeriodically>false</UpdatePeriodically> + <UpdateRequired>false</UpdateRequired> + <MapFileExtensions>true</MapFileExtensions> + <ApplicationRevision>0</ApplicationRevision> + <ApplicationVersion>1.0.0.%2a</ApplicationVersion> + <IsWebBootstrapper>false</IsWebBootstrapper> + <UseApplicationTrust>false</UseApplicationTrust> + <BootstrapperEnabled>true</BootstrapperEnabled> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> + <RegisterForComInterop>false</RegisterForComInterop> + <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> + </PropertyGroup> + <ItemGroup> + <Reference Include="ESRI.ArcGIS.ADF.Local, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86, processorArchitecture=x86"> + <SpecificVersion>False</SpecificVersion> + </Reference> + <Reference Include="ESRI.ArcGIS.Carto, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86, processorArchitecture=x86"> + <SpecificVersion>False</SpecificVersion> + <EmbedInteropTypes>True</EmbedInteropTypes> + </Reference> + <Reference Include="ESRI.ArcGIS.Catalog, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86, processorArchitecture=x86"> + <SpecificVersion>False</SpecificVersion> + <EmbedInteropTypes>True</EmbedInteropTypes> + </Reference> + <Reference Include="ESRI.ArcGIS.Desktop.AddIns, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86, processorArchitecture=x86"> + <SpecificVersion>False</SpecificVersion> + <Private>False</Private> + </Reference> + <Reference Include="ESRI.ArcGIS.Display, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86, processorArchitecture=x86"> + <SpecificVersion>False</SpecificVersion> + <EmbedInteropTypes>True</EmbedInteropTypes> + </Reference> + <Reference Include="ESRI.ArcGIS.Framework"> + <Private>False</Private> + </Reference> + <Reference Include="ESRI.ArcGIS.Geodatabase, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86, processorArchitecture=x86"> + <SpecificVersion>False</SpecificVersion> + <EmbedInteropTypes>True</EmbedInteropTypes> + </Reference> + <Reference Include="ESRI.ArcGIS.Geometry, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86, processorArchitecture=x86"> + <SpecificVersion>False</SpecificVersion> + <EmbedInteropTypes>True</EmbedInteropTypes> + </Reference> + <Reference Include="ESRI.ArcGIS.System"> + <Private>False</Private> + </Reference> + </ItemGroup> + <ItemGroup> + <Reference Include="Npgsql"> + <HintPath>..\..\..\Downloads\Npgsql2.0.11.93-bin-ms.net3.5sp1\Npgsql.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Data" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Drawing" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Postarc\Catalog\FeatureClassExporter.cs" /> + <Compile Include="Postarc\Feature\Feature.cs" /> + <Compile Include="Postarc\Feature\FeatureCursor.cs" /> + <Compile Include="Postarc\Feature\IWKTGeometry.cs" /> + <Compile Include="Postarc\Feature\FeatureLayer.cs" /> + <Compile Include="Postarc\Feature\Point.cs" /> + <Compile Include="Postarc\Feature\Polygon.cs" /> + <Compile Include="Postarc\Feature\Polyline.cs" /> + <Compile Include="Postarc\Feature\Workspace.cs" /> + <Compile Include="Postarc\Feature\WorkspaceFactory.cs" /> + <Compile Include="Postarc\Geodatabase\DummyClassExtension.cs" /> + <Compile Include="Postarc\Geodatabase\FeatureDataset.cs" /> + <Compile Include="Postarc\Geodatabase\FieldInfo.cs" /> + <Compile Include="Postarc\Geodatabase\SelectionSet.cs" /> + <Compile Include="Postarc\Geodatabase\SelectionSetEnumerator.cs" /> + <Compile Include="Postarc\GUI\ButtonExportToPostGIS.cs" /> + <Compile Include="Postarc\GUI\ButtonNewPostGISLayer.cs" /> + <Compile Include="Config.Designer.cs"> + <AutoGen>True</AutoGen> + <DependentUpon>Config.esriaddinx</DependentUpon> + </Compile> + <Compile Include="Postarc\GUI\FormConnectionProperties.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Postarc\GUI\FormConnectionProperties.Designer.cs"> + <DependentUpon>FormConnectionProperties.cs</DependentUpon> + </Compile> + <Compile Include="Postarc\GUI\FormExportToPostGIS.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Postarc\GUI\FormExportToPostGIS.Designer.cs"> + <DependentUpon>FormExportToPostGIS.cs</DependentUpon> + </Compile> + <Compile Include="Postarc\GUI\FormNewPostGISFeatClass.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Postarc\GUI\FormNewPostGISFeatClass.Designer.cs"> + <DependentUpon>FormNewPostGISFeatClass.cs</DependentUpon> + </Compile> + <Compile Include="Postarc\Catalog\GxAddNewPostGISConnection.cs" /> + <Compile Include="Postarc\Catalog\GxPostGISDatabase.cs" /> + <Compile Include="Postarc\PostArcCOMHelper.cs" /> + <Compile Include="Postarc\PostArcClassDescription.cs" /> + <Compile Include="Postarc\PostGISConnection.cs" /> + <Compile Include="Postarc\Feature\FeatureClass.cs" /> + <Compile Include="Postarc\Feature\FeatureClassName.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Postarc\Settings.cs" /> + </ItemGroup> + <ItemGroup> + <AddInContent Include="Config.esriaddinx"> + <Generator>ArcGISAddInHostGenerator</Generator> + <LastGenOutput>Config.Designer.cs</LastGenOutput> + </AddInContent> + </ItemGroup> + <ItemGroup> + <AddInContent Include="Images\PostArc.png" /> + </ItemGroup> + <ItemGroup> + <AddInContent Include="Images\Button1.png" /> + </ItemGroup> + <ItemGroup> + <Reference Include="ESRI.ArcGIS.ArcMapUI"> + <Private>False</Private> + </Reference> + </ItemGroup> + <ItemGroup> + <BootstrapperPackage Include="Microsoft.Net.Client.3.5"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName> + <Install>false</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.5 SP1</ProductName> + <Install>true</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1"> + <Visible>False</Visible> + <ProductName>Windows Installer 3.1</ProductName> + <Install>true</Install> + </BootstrapperPackage> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="Postarc\GUI\FormConnectionProperties.resx"> + <DependentUpon>FormConnectionProperties.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Postarc\GUI\FormExportToPostGIS.resx"> + <DependentUpon>FormExportToPostGIS.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Postarc\GUI\FormNewPostGISFeatClass.resx"> + <DependentUpon>FormNewPostGISFeatClass.cs</DependentUpon> + </EmbeddedResource> + </ItemGroup> + <ItemGroup> + <AddInContent Include="Images\ButtonNewPostGISLayer.png" /> + </ItemGroup> + <ItemGroup> + <AddInContent Include="Images\ButtonNewPostGISLayer_16.png" /> + </ItemGroup> + <PropertyGroup> + <ZipFileExtension>esriAddIn</ZipFileExtension> + <AddInTargetProduct>Desktop</AddInTargetProduct> + <AddInTargetVersion>10.0</AddInTargetVersion> + </PropertyGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <Import Project="$(MSBuildExtensionsPath)\ESRI\ESRI.ArcGIS.AddIns.targets" Condition="Exists('$(MSBuildExtensionsPath)\ESRI\ESRI.ArcGIS.AddIns.targets')" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + --> + <Target Name="AfterBuild"> + <!-- Gives build warning when add-in targets file is not found. --> + <Warning Text="Unable to create .esriAddin; missing ESRI ArcGIS Add-in SDK component(s)." Condition="!Exists('$(MSBuildExtensionsPath)\ESRI\ESRI.ArcGIS.AddIns.targets')" /> + </Target> + <ProjectExtensions> + <!-- Default ESRI add-in properties --> + <ESRIAddInProperties> + <Host>ArcMap</Host> + </ESRIAddInProperties> + </ProjectExtensions> +</Project> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc.sln Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Postarc", "Postarc.csproj", "{C9F8C93D-2614-4675-9897-2BD9ACBC32D7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + DebugDSProjection|Any CPU = DebugDSProjection|Any CPU + Release|Any CPU = Release|Any CPU + ReleaseDSProjection|Any CPU = ReleaseDSProjection|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C9F8C93D-2614-4675-9897-2BD9ACBC32D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C9F8C93D-2614-4675-9897-2BD9ACBC32D7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C9F8C93D-2614-4675-9897-2BD9ACBC32D7}.DebugDSProjection|Any CPU.ActiveCfg = Debug|Any CPU + {C9F8C93D-2614-4675-9897-2BD9ACBC32D7}.DebugDSProjection|Any CPU.Build.0 = Debug|Any CPU + {C9F8C93D-2614-4675-9897-2BD9ACBC32D7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C9F8C93D-2614-4675-9897-2BD9ACBC32D7}.Release|Any CPU.Build.0 = Release|Any CPU + {C9F8C93D-2614-4675-9897-2BD9ACBC32D7}.ReleaseDSProjection|Any CPU.ActiveCfg = Release|Any CPU + {C9F8C93D-2614-4675-9897-2BD9ACBC32D7}.ReleaseDSProjection|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/Catalog/FeatureClassExporter.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,232 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ESRI.ArcGIS.Geodatabase; +using ESRI.ArcGIS.Geometry; +using Npgsql; + +namespace Postarc.Catalog +{ + public class FeatureClassExporter + { + protected IFeatureClass featureClass; + + public FeatureClassExporter(IFeatureClass featClass) + { + this.featureClass = featClass; + } + + protected string CreateTableDefinition(IFields fields, string tableName) + { + StringBuilder buf = new StringBuilder(); + buf.Append("CREATE TABLE "); + buf.Append(tableName); + buf.Append(" ( "); + + bool hasOID = false; + for (int n = 0; n < fields.FieldCount; n++) + { + IField field = fields.get_Field(n); + string fieldType = GetSQLType(field.Type); + if (fieldType != null) + { + if (field.Name.Equals(Postarc.Feature.FeatureCursor.ARCGIS_OID_COLUMN, StringComparison.InvariantCultureIgnoreCase)) + { + hasOID = true; + buf.Append(Postarc.Feature.FeatureCursor.POSTARC_OID_COLUMN); + } + else + { + buf.Append(field.Name); + } + buf.Append(" "); + buf.Append(fieldType); + buf.Append(","); + } + + if (!hasOID && n == fields.FieldCount - 1) + { + buf.Append(Postarc.Feature.FeatureCursor.POSTARC_OID_COLUMN); + buf.Append(" BIGSERIAL NOT NULL,"); + } + } + + buf.Append("PRIMARY KEY("); + buf.Append(Postarc.Feature.FeatureCursor.POSTARC_OID_COLUMN); + buf.Append(")"); + buf.Append(" )"); + return buf.ToString(); + } + + protected string CreateGeoColumnDef(string tableName) + { + StringBuilder buf = new StringBuilder(); + + buf.Append("SELECT AddGeometryColumn('public', '"); + buf.Append(tableName); + buf.Append("', '"); + buf.Append(Postarc.Feature.FeatureCursor.POSTARC_SHAPE_COLUMN); + buf.Append("', -1, 'POINT', 2)"); + + return buf.ToString(); + } + + protected string GetSQLType(esriFieldType type) + { + switch (type) + { + case esriFieldType.esriFieldTypeInteger: + return "INT"; + // case esriFieldType.esriFieldTypeString: + // return "TEXT"; + } + return null; + } + + protected string CreateInsertStatement(string tableName, object[] row) + { + StringBuilder buf = new StringBuilder(); + buf.Append("INSERT INTO "); + buf.Append(tableName); + buf.Append("("); + + List<string> fields = new List<string>(); + for (int n = 0; n < featureClass.Fields.FieldCount; n++) + { + IField field = featureClass.Fields.get_Field(n); + string fieldType = GetSQLType(field.Type); + + if (fieldType != null) + { + fields.Add(field.Name); + } + else if (field.Type == esriFieldType.esriFieldTypeGeometry) + { + fields.Add(Postarc.Feature.FeatureCursor.POSTARC_SHAPE_COLUMN); + } + } + + for (int n = 0; n < fields.Count; n++) + { + buf.Append(fields[n]); + if (n < fields.Count - 1) + buf.Append(","); + } + + buf.Append(") VALUES ("); + + List<string> values = new List<string>(); + for (int n = 0; n < row.Length; n++) + { + esriFieldType fieldType = featureClass.Fields.get_Field(n).Type; + + if (GetSQLType(fieldType) != null || fieldType == esriFieldType.esriFieldTypeGeometry) + { + values.Add("'" + row[n] + "'"); + } + } + + for (int n = 0; n < values.Count; n++) + { + buf.Append(values[n]); + if (n < values.Count - 1) + buf.Append(","); + } + + buf.Append(")"); + return buf.ToString(); + } + + protected void CreateTable(PostGISConnection conn, string tableName) + { + NpgsqlConnection npgsqlConn = conn.Open(); + string sql; + NpgsqlCommand cmd; + + sql = CreateTableDefinition(featureClass.Fields, tableName); + cmd = new NpgsqlCommand(sql, npgsqlConn); + cmd.ExecuteNonQuery(); + + sql = CreateGeoColumnDef(tableName); + cmd = new NpgsqlCommand(sql, npgsqlConn); + cmd.ExecuteNonQuery(); + } + + protected object[] CreateRow(IFeature feature) + { + object[] row = new object[feature.Fields.FieldCount]; + for (int n = 0; n < row.Length; n++) + { + row[n] = feature.get_Value(n); + if (row[n] is IGeometry) + { + Postarc.Feature.Point point = new Postarc.Feature.Point(row[n] as IPoint); + row[n] = point.GetWKT(); + } + else if (feature.Fields.get_Field(n).Type == esriFieldType.esriFieldTypeString) + { + row[n] = EscapeString(row[n] as string); + } + } + return row; + } + + protected string EscapeString(string str) + { + str = str.Replace("'", "\'"); + return str; + } + + protected int WriteRow(string tableName, NpgsqlConnection conn, object[] row) + { + string sql = CreateInsertStatement(tableName, row); + NpgsqlCommand cmd = new NpgsqlCommand(sql, conn); + return cmd.ExecuteNonQuery(); + } + + public int ExportFeatureClass(IQueryFilter filter, PostGISConnection conn, string tableName) + { + // FIXME: Enclose in transaction + CreateTable(conn, tableName); + + NpgsqlConnection npgsqlConn = conn.Open(); + int numExported = 0; + + IFeatureCursor cursor = this.featureClass.Search(filter, true); + IFeature ifeature; + while ((ifeature = cursor.NextFeature()) != null) + { + object[] row = CreateRow(ifeature); + WriteRow(tableName, npgsqlConn, row); + numExported++; + } + + npgsqlConn.Close(); + return numExported; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/Catalog/GxAddNewPostGISConnection.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,226 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Runtime.InteropServices; +using ESRI.ArcGIS.Catalog; +using ESRI.ArcGIS.esriSystem; + +namespace Postarc.Catalog +{ + [Guid("980885BD-E760-4FE8-9A99-4153EA116886")] + public class GxAddNewPostGISConnection : + IGxBasicObject, + IGxObject, + IGxObjectUI, + IGxObjectWizard, + IGxObjectEdit, IGxObjectProperties + { + public void Invoke(int hParentWnd) + { + /// throw new NotImplementedException(); + } + + public void Attach(IGxObject Parent, IGxCatalog pCatalog) + { + //throw new NotImplementedException(); + } + + public string BaseName + { + get + { + return "AddNewPostGIS"; + } + } + + public string Category + { + get + { + throw new NotImplementedException(); + } + } + + public ESRI.ArcGIS.esriSystem.UID ClassID + { + get + { + UID clsid = new UIDClass(); + clsid.Value = "{980885BD-E760-4FE8-9A99-4153EA116886}"; + return clsid; + } + } + + public void Detach() + { + throw new NotImplementedException(); + } + + public string FullName + { + get + { + throw new NotImplementedException(); + } + } + + public ESRI.ArcGIS.esriSystem.IName InternalObjectName + { + get + { + throw new NotImplementedException(); + } + } + + public bool IsValid + { + get + { + throw new NotImplementedException(); + } + } + + public string Name + { + get + { + throw new NotImplementedException(); + } + } + + public IGxObject Parent + { + get + { + throw new NotImplementedException(); + } + } + + public void Refresh() + { + throw new NotImplementedException(); + } + + public ESRI.ArcGIS.esriSystem.UID ContextMenu + { + get + { + throw new NotImplementedException(); + } + } + + public int LargeImage + { + get + { + throw new NotImplementedException(); + } + } + + public int LargeSelectedImage + { + get + { + throw new NotImplementedException(); + } + } + + public ESRI.ArcGIS.esriSystem.UID NewMenu + { + get + { + throw new NotImplementedException(); + } + } + + public int SmallImage + { + get + { + throw new NotImplementedException(); + } + } + + public int SmallSelectedImage + { + get + { + throw new NotImplementedException(); + } + } + + public bool CanCopy() + { + throw new NotImplementedException(); + } + + public bool CanDelete() + { + throw new NotImplementedException(); + } + + public bool CanRename() + { + throw new NotImplementedException(); + } + + public void Delete() + { + throw new NotImplementedException(); + } + + public void EditProperties(int hParent) + { + throw new NotImplementedException(); + } + + public void Rename(string newShortName) + { + throw new NotImplementedException(); + } + + public void GetPropByIndex(int index, ref string Name, ref object value) + { + throw new NotImplementedException(); + } + + public object GetProperty(string Name) + { + throw new NotImplementedException(); + } + + public int PropertyCount + { + get { throw new NotImplementedException(); } + } + + public void SetProperty(string Name, object value) + { + throw new NotImplementedException(); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/Catalog/GxPostGISDatabase.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,90 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ESRI.ArcGIS.Catalog; +using System.Runtime.InteropServices; + +namespace Postarc.Catalog +{ + [Guid("D875D48E-2567-4297-981B-2654446A07C9")] + class GxPostGISDatabase : IGxDatabase, IGxDatabase2 + { + public void Disconnect() + { + + } + + public bool IsConnected + { + get + { + throw new NotImplementedException(); + } + } + + public bool IsRemoteDatabase + { + get + { + throw new NotImplementedException(); + } + } + + public ESRI.ArcGIS.Geodatabase.IWorkspace Workspace + { + get + { + throw new NotImplementedException(); + } + } + + public ESRI.ArcGIS.Geodatabase.IWorkspaceName WorkspaceName + { + get + { + throw new NotImplementedException(); + } + set + { + throw new NotImplementedException(); + } + } + + public void Connect() + { + throw new NotImplementedException(); + } + + public bool IsEnterpriseGeodatabase + { + get + { + throw new NotImplementedException(); + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/Feature/Feature.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,285 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ESRI.ArcGIS.Geodatabase; +using Npgsql; +using ESRI.ArcGIS.Geometry; +using System.Diagnostics; + +namespace Postarc.Feature +{ + public class Feature : IFeature, IFeatureBuffer, IRow, IRowBuffer + { + protected FeatureClass featureClass; + protected IFields fields; + protected object[] row; + protected IWKTGeometry shape = new Point(); + + private int oidIdx = -1; + + /// <summary> + /// Constructs a Feature from an existing row in a database table. + /// </summary> + /// <param name="featureClass"></param> + /// <param name="reader"></param> + /// <param name="oidIdx"></param> + /// <param name="fields"></param> + public Feature(FeatureClass featureClass, IFields fields, int oidIdx, + NpgsqlDataReader reader) : this(featureClass, fields, oidIdx) + { + this.row = new object[fields.FieldCount]; + reader.GetValues(this.row); + LoadShapeFromRow(); + } + + protected Feature(FeatureClass featureClass, IFields fields, int oidIdx) + { + this.featureClass = featureClass; + this.fields = fields; + this.oidIdx = oidIdx; + } + + protected int ShapeFieldIndex + { + get + { + return this.fields.FindField(featureClass.ShapeFieldName); + } + } + + /// <summary> + /// Creates a new feature which is not yet written to a backend. + /// </summary> + /// <param name="featureClass"></param> + /// <param name="fields"></param> + /// <param name="oidIdx"></param> + /// <param name="row"></param> + public Feature(FeatureClass featureClass, IFields fields, int oidIdx, + object[] row) : this(featureClass, fields, oidIdx) + { + this.row = row; + LoadShapeFromRow(); + } + + protected void LoadShapeFromRow() + { + this.shape = new Point(); + int shpIdx = ShapeFieldIndex; + if (shpIdx >= 0 && row[ShapeFieldIndex] != null) + { + this.shape.SetWKT(row[ShapeFieldIndex] as string); + } + } + + public IObjectClass Class + { + get { throw new NotImplementedException(); } + } + + public void Delete() + { + // TODO: Not implemented + } + + public IEnvelope Extent + { + get + { + return this.Shape.Envelope; + } + } + + public esriFeatureType FeatureType + { + get + { + return this.featureClass.FeatureType; + } + } + + public IFields Fields + { + get + { + return this.fields; + } + } + + public bool HasOID + { + get + { + return oidIdx >= 0; + } + } + + public int OID + { + get + { + if (oidIdx >= 0) + { + int oid = Convert.ToInt32(this.row[oidIdx]); + return oid; + } + else + { + return -1; + } + } + } + + public IGeometry Shape + { + get + { + return this.shape as IGeometry; + } + set + { + this.shape = value as IWKTGeometry; + } + } + + public IGeometry ShapeCopy + { + get { throw new NotImplementedException(); } + } + + /// <summary> + /// Writes the row to the backend. From IRow interface. + /// </summary> + public void Store() + { + StringBuilder sql = new StringBuilder(); + NpgsqlConnection conn = featureClass.PostGISConnection.Open(); + NpgsqlCommand cmd; + + if (OID > 0) + { // Update existing row + sql.Append("UPDATE "); + sql.Append(featureClass.TableName); + sql.Append(" SET "); + for (int n = 0; n < this.row.Length; n++) + { + if (n != this.oidIdx) + { + sql.Append(Fields.get_Field(n).Name); + sql.Append(" = '"); + if (n == featureClass.ShapeFieldIndex) + sql.Append(shape.GetWKT()); + else + sql.Append(this.row[n]); + sql.Append("',"); + } + } + sql.Replace(',',' ', sql.Length - 1, 1); + sql.Append(" WHERE "); + sql.Append(FeatureCursor.POSTARC_OID_COLUMN); + sql.Append(" = "); + sql.Append(OID); + } + else + { // Create new row + sql.Append("INSERT INTO "); + sql.Append(featureClass.TableName); + sql.Append(" ("); + for (int n = 0; n < this.row.Length; n++) + { + if (n == this.oidIdx) + sql.Append(FeatureCursor.POSTARC_OID_COLUMN); + else + sql.Append(Fields.get_Field(n).Name); + + if (n != Fields.FieldCount - 1) + sql.Append(","); + } + sql.Append(" ) SELECT "); + for (int n = 0; n < this.row.Length; n++) + { + if (n == this.oidIdx) + { + sql.Append("Max("); + sql.Append(FeatureCursor.POSTARC_OID_COLUMN); + sql.Append(") + 1"); + } + else + { + sql.Append("'"); + if (n == featureClass.ShapeFieldIndex) + { + sql.Append(shape.GetWKT()); + } + else + { + sql.Append(this.row[n]); + } + sql.Append("'"); + } + if (n != Fields.FieldCount - 1) + sql.Append(","); + } + sql.Append(" FROM "); + sql.Append(featureClass.TableName); + } + + cmd = new NpgsqlCommand(sql.ToString(), conn); + int updatedRows = cmd.ExecuteNonQuery(); + conn.Close(); + Debug.WriteLine("Feature::Store: " + updatedRows + " rows affected"); + } + + public ITable Table + { + get + { + return this.featureClass; + } + } + + public object get_Value(int index) + { + Debug.WriteLine("Feature::get_Value(" + index + "): " + + (row[index] != null ? row[index].GetType() + " " + row[index].ToString() : "")); + + if (index == featureClass.ShapeFieldIndex) + { + return this.Shape; + } + else + { + return this.row[index]; + } + } + + public void set_Value(int index, object value) + { + Debug.WriteLine("Feature::set_Value(" + index + ", " + value + ")"); + this.row[index] = value; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/Feature/FeatureClass.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,1084 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ESRI.ArcGIS.Geodatabase; +using ESRI.ArcGIS.Geometry; +using ESRI.ArcGIS.esriSystem; +using Npgsql; +using NpgsqlTypes; +using System.Runtime.InteropServices; +using System.Diagnostics; +using Postarc.Geodatabase; + +namespace Postarc.Feature +{ + [Guid("77FB1E58-69A9-4bac-AFB6-76F0F85D3B75"), ClassInterface(ClassInterfaceType.None)] + public class FeatureClass : + IDataset, IDatasetEdit, IDatasetEditInfo, + IFeatureClass, + IGeoDataset, + //IModelInfo, + ISchemaLock, + ISubtypes, + ITable /* inherits IClass */, ITableCapabilities, + ITopology, + IValidation, IValidation2 + { + private string browseName = "BrowseName"; + private string clsid = "{77FB1E58-69A9-4bac-AFB6-76F0F85D3B75}"; + private IFields fields = new FieldsClass(); + private string shapeFieldName = "shape"; + private esriGeometryType shapeType = esriGeometryType.esriGeometryPoint; + + protected PostGISConnection connection; + protected ISpatialReference spatialReference = FeatureLayer.CreateGeographicSpatialReference(); + protected string tableName; + protected Workspace workspace = new Workspace(); + + internal PostGISConnection PostGISConnection + { + get + { + return this.connection; + } + } + + /// <summary> + /// Name of the PostGIS table behind this FeatureClass. + /// </summary> + internal string TableName + { + get + { + return this.tableName; + } + } + + public FeatureClass(esriGeometryType shapeType) + { + this.shapeType = shapeType; + + IFieldEdit field = new FieldClass(); + field.Name_2 = "OID"; + field.Type_2 = esriFieldType.esriFieldTypeOID; + AddField(field); + + field = new FieldClass(); + field.Name_2 = ShapeFieldName; + field.Type_2 = esriFieldType.esriFieldTypeGeometry; + AddField(field as IField); + + field = new FieldClass(); + field.Name_2 = "test"; + field.Type_2 = esriFieldType.esriFieldTypeInteger; + // AddField(field as IField); + } + + public FeatureClass(PostGISConnection conn, string tableName) + { + this.connection = conn; + this.tableName = tableName; + + LoadFieldDefinitionFromTable(); + } + + /// <summary> + /// + /// </summary> + /// <returns></returns> + protected internal int NextOID() + { + NpgsqlConnection conn = this.connection.Open(); + NpgsqlCommand cmd = new NpgsqlCommand( + "SELECT Max(" + FeatureCursor.POSTARC_OID_COLUMN + ") FROM " + tableName, conn); + int maxOID = Convert.ToInt32(cmd.ExecuteScalar()); + conn.Close(); + return maxOID + 1; + } + + protected internal void LoadFieldDefinitionFromTable() + { + NpgsqlConnection conn = this.connection.Open(); + + NpgsqlCommand cmd = new NpgsqlCommand("SELECT * FROM " + tableName + " LIMIT 1", conn); + NpgsqlDataReader cur = cmd.ExecuteReader(); + for (int n = 0; n < cur.FieldCount; n++) + { + NpgsqlDbType type = cur.GetFieldNpgsqlDbType(n); + string name = cur.GetName(n); + if (name.Equals(FeatureCursor.POSTARC_OID_COLUMN, StringComparison.OrdinalIgnoreCase)) + { + name = FeatureCursor.ARCGIS_OID_COLUMN; + AddField(name, type, true); + } + else if (name.Equals(FeatureCursor.POSTARC_SHAPE_COLUMN, StringComparison.OrdinalIgnoreCase)) + { + type = NpgsqlDbType.Point; + AddField(name, type); + } + else + { + AddField(name, type); + } + } + conn.Close(); + } + + protected void AddField(string name, NpgsqlDbType type, bool isOID = false) + { + esriFieldType esriType = esriFieldType.esriFieldTypeBlob; + switch (type) + { + case NpgsqlDbType.Bigint: + case NpgsqlDbType.Integer: + if (isOID) + { + esriType = esriFieldType.esriFieldTypeOID; + AddField(name, esriType, false); + } + else + { + esriType = esriFieldType.esriFieldTypeInteger; + AddField(name, esriType); + } + break; + case NpgsqlDbType.Point: + esriType = esriFieldType.esriFieldTypeGeometry; + this.shapeType = esriGeometryType.esriGeometryPoint; + this.shapeFieldName = name; + AddField(name, esriType, true, true); + break; + case NpgsqlDbType.Varchar: + esriType = esriFieldType.esriFieldTypeString; + AddField(name, esriType, true, false, 255); + break; + } + } + + protected void AddField( + string name, + esriFieldType type, + bool editable = true, + bool isGeometry = false, + int length = 4) + { + IFieldEdit field = new FieldClass(); + field.Name_2 = name; + field.Type_2 = type; + field.AliasName_2 = name; + field.Editable_2 = editable; + if (isGeometry) + { + field.GeometryDef_2 = new Point() as IGeometryDef; + Debug.Assert(field.GeometryDef != null); + } + field.Length_2 = length; + AddField(field as IField); + } + + public void AddField(IField field) + { + IFieldsEdit fields = this.fields as IFieldsEdit; + fields.AddField(field); + } + + public void AddIndex(IIndex Index) + { + + } + + public string AliasName + { + get + { + return "AliasName"; + } + } + + public IField AreaField + { + get + { + return null; // null is correct when ShapeType is point + } + } + + public UID CLSID + { + get + { + UID uid = new UID(); + uid.Value = clsid; + return uid; + } + } + + /// <summary> + /// Calls CreateFeatureBuffer() + /// </summary> + /// <returns></returns> + public IFeature CreateFeature() + { + Debug.WriteLine("PostGISFeatureClass::CreateFeature()"); + return CreateFeatureBuffer() as IFeature; + } + + /// <summary> + /// Creates a new Postarc.Feature.Feature instance as IFeatureBuffer. + /// </summary> + /// <returns></returns> + public IFeatureBuffer CreateFeatureBuffer() + { + Debug.WriteLine("PostGISFeatureClass::CreateFeatureBuffer()"); + int oidIdx = fields.FindField(FeatureCursor.ARCGIS_OID_COLUMN); + object[] row = new object[fields.FieldCount]; + row[oidIdx] = NextOID(); + return new Feature(this, fields, oidIdx, row); + } + + public void DeleteField(IField Field) + { + + } + + public void DeleteIndex(IIndex Index) + { + + } + + public ESRI.ArcGIS.esriSystem.UID EXTCLSID + { + get + { + return null; + } + } + + public object Extension + { + get + { + return new DummyClassExtension() as IClassExtension; + } + } + + public IPropertySet ExtensionProperties + { + get + { + Debug.WriteLine("PostGISFeatureClass::ExtensionProperties"); + return new PropertySetClass(); + } + } + + public int FeatureClassID + { + get + { + return GetHashCode(); // TODO: Return unique ID for this feature class + } + } + + public int FeatureCount(IQueryFilter QueryFilter) + { + NpgsqlConnection conn = this.connection.Open(); + NpgsqlCommand cmd = new NpgsqlCommand("SELECT Count(*) FROM " + tableName, conn); + int cnt = Convert.ToInt32(cmd.ExecuteScalar()); + conn.Close(); + return cnt; + } + + public IFeatureDataset FeatureDataset + { + get + { + return new Postarc.Geodatabase.FeatureDataset(this); + } + } + + public esriFeatureType FeatureType + { + get + { + return esriFeatureType.esriFTSimple; + } + } + + public IFields Fields + { + get + { + return fields; + } + } + + public int FindField(string Name) + { + return this.fields.FindField(Name); + } + + public IFeature GetFeature(int oid) + { + QueryFilterClass filter = new QueryFilterClass(); + filter.WhereClause = "OID in (" + oid + ")"; + IFeatureCursor cur = Search(filter, false); + return cur.NextFeature(); + } + + public IFeatureCursor GetFeatures(object fids, bool recycling) + { + QueryFilterClass filter = new QueryFilterClass(); + StringBuilder buf = new StringBuilder(); + buf.Append(FeatureCursor.POSTARC_OID_COLUMN); + buf.Append(" in ("); + int[] oids = (int[])fids; + for (int n = 0; n < oids.Length; n++) + { + buf.Append(oids[n]); + if (n != oids.Length - 1) + buf.Append(","); + } + buf.Append(")"); + filter.WhereClause = buf.ToString(); + + return new FeatureCursor(this, this.connection, filter); + } + + public bool HasOID + { + get + { + return true; + } + } + + public IIndexes Indexes + { + get + { + return null; + } + } + + public IFeatureCursor Insert(bool useBuffering) + { + return null; + } + + ICursor ITable.Insert(bool useBuffering) + { + return null; + } + + public IField LengthField + { + get + { + return null; + } + } + + public string OIDFieldName + { + get + { + return "OID"; + } + } + + public int ObjectClassID + { + get + { + return -1; + } + } + + public IFeatureCursor Search(IQueryFilter filter, bool recycling) + { + return new FeatureCursor(this, this.connection, filter); + } + + ICursor ITable.Search(IQueryFilter filter, bool recycling) + { + return Search(filter, recycling) as ICursor; + } + + public ISelectionSet Select( + IQueryFilter queryFilter, + esriSelectionType selType, + esriSelectionOption selOption, + IWorkspace selectionContainer) + { + Postarc.Geodatabase.SelectionSet sel = new Postarc.Geodatabase.SelectionSet(this); + IFeatureCursor cur = Search(queryFilter, false); + IFeature feature; + while ((feature = cur.NextFeature()) != null) + { + sel.Add(feature.OID); + } + //return sel as ISelectionSet; + return null; + } + + public string ShapeFieldName + { + get + { + return this.shapeFieldName; + } + } + + internal int ShapeFieldIndex + { + get + { + return Fields.FindField(shapeFieldName); + } + } + + public esriGeometryType ShapeType + { + get + { + return this.shapeType; + } + } + + public IFeatureCursor Update(IQueryFilter filter, bool recycling) + { + return null; + } + + ICursor ITable.Update(IQueryFilter filter, bool recycling) + { + return null; + } + + public IEnumRelationshipClass get_RelationshipClasses(esriRelRole role) + { + Debug.WriteLine("FeatureClass::get_RelationshipClasses(): FIXME"); + return null; // TODO: ? + } + + public string BrowseName + { + get + { + return this.browseName; + } + set + { + this.browseName = value; + } + } + + public bool CanCopy() + { + return false; + } + + public bool CanDelete() + { + return false; + } + + public bool CanRename() + { + return false; + } + + public string Category + { + get + { + return "PostGIS"; + } + } + + public IDataset Copy(string copyName, IWorkspace copyWorkspace) + { + return null; + } + + public void Delete() + { + + } + + public IName FullName + { + get + { + return new FeatureClassName(); + } + } + + public string Name + { + get + { + return "PostGIS FeatureClass"; + } + } + + public IPropertySet PropertySet + { + get + { + return null; + } + } + + public void Rename(string name) + { + } + + public IEnumDataset Subsets + { + get + { + return null; + } + } + + public esriDatasetType Type + { + get + { + return esriDatasetType.esriDTFeatureClass; + } + } + + /// <summary> + /// Returns the associated Postarc.Feature.Workspace instance of this + /// FeatureClass. + /// </summary> + public IWorkspace Workspace + { + get + { + return this.workspace as IWorkspace; + } + } + + /// <summary> + /// From IDatasetEdit + /// </summary> + /// <returns></returns> + public bool IsBeingEdited() + { + return this.workspace.IsBeingEdited(); + } + + public void AlterAliasName(string Name) + { + + } + + public void AlterClassExtensionCLSID(UID ClassExtensionCLSID, IPropertySet classExtensionProperties) + { + + } + + public void AlterDefaultValue(string FieldName, object Value) + { + + } + + public void AlterDomain(string FieldName, IDomain Domain) + { + + } + + public void AlterFieldAliasName(string FieldName, string AliasName) + { + + } + + public void AlterFieldModelName(string FieldName, string ModelName) + { + + } + + public void AlterInstanceCLSID(UID InstanceCLSID) + { + + } + + public void AlterModelName(string Name) + { + + } + + public int RegisterAsObjectClass(string suggestedOIDFieldName, string configKeyword) + { + return 0; // FIXME + } + + + public void AlterClassExtensionProperties(IPropertySet classExtensionProperties) + { + + } + + public void AddGlobalID(string FieldName) + { + + } + + public void DeleteGlobalID() + { + + } + + /* public int AllowableComponents + { + get + { + return 0; // FIXME + } + } + + public void Analyze(int tableComponents) + { + + }*/ + + public bool CanEdit + { + get + { + // TODO: Check for write access to PostGIS table + return true; + } + } + + + public bool CanRedo + { + get + { + return false; + } + } + + public bool CanUndo + { + get + { + return false; + } + } + + /// <summary> + /// IFeatureClassLoad.LoadOnlyMode: Indicates if the featureclass is in load only mode. + /// </summary> + /*public bool LoadOnlyMode + { + get + { + return true; //FIXME + } + set + { + + } + }*/ + + /* + public void UpdateExtent() + { + + }*/ + + /* + public void RemoveFeature(IFeature Feature) + { + + } + + public void RemoveFeatures(ISet features) + { + + } + + public void WriteFeature(IFeature Feature) + { + + } + + public void WriteFeatures(ISet features) + { + + }*/ + + public IEnvelope Extent + { + get + { + IPoint point = new PointClass(); + point.PutCoords(0, 0); + ITopologicalOperator topOp = point as ITopologicalOperator; + IGeometry buf = topOp.Buffer(100); + return buf.Envelope; + } + } + + public ISpatialReference SpatialReference + { + get + { + return spatialReference; + } + } + + + /*public IGeodataXform GeodataXform + { + get + { + return null; //FIXME + } + } + + public IEnvelope NativeExtent + { + get + { + return null; //FIXME + } + } + + public ISpatialReference NativeSpatialReference + { + get + { + return null; // FIXME + } + }*/ + + public string ModelName + { + get + { + return "ModelName"; //FIXME + } + set + { + + } + } + + + public IGeometricNetwork GeometricNetwork + { + get + { + return null; // FIXME + } + } + + public esriNetworkClassAncillaryRole NetworkAncillaryRole + { + get + { + return esriNetworkClassAncillaryRole.esriNCARNone; //FIXME + } + } + + public int get_FieldToWeightMapping(int FieldIndex) + { + return 0;//FIXME + } + + public bool CanBypassStoreMethod() + { + return false; + } + + public bool CanBypassEditSession() + { + return false; + } + + public void ChangeSchemaLock(esriSchemaLock schemaLock) + { + + } + + public void GetCurrentSchemaLocks(out IEnumSchemaLockInfo schemaLockInfo) + { + schemaLockInfo = null; // FIXME + } + + public void AddSubtype(int SubtypeCode, string SubtypeName) + { + + } + + public int DefaultSubtypeCode + { + get + { + return 0; //FIXME + } + set + { + + } + } + + public void DeleteSubtype(int SubtypeCode) + { + + } + + public bool HasSubtype + { + get + { + return false; + } + } + + public int SubtypeFieldIndex + { + get + { + Debug.WriteLine("FeatureClass::SubtypeFieldIndex::get"); + return 0; //FIXME + } + } + + public string SubtypeFieldName + { + get + { + return ""; + } + set + { + + } + } + + public IEnumSubtype Subtypes + { + get + { + Debug.WriteLine("FeatureClass::Subtypes(): FIXME"); + return null; //FIXME + } + } + + public object get_DefaultValue(int subtypeCode, string fieldName) + { + return null; // FIXME + } + + public IDomain get_Domain(int subtypeCode, string fieldName) + { + Debug.WriteLine("FeatureClass::get_Domain(): FIXME " + fieldName); + return null; //FIXME + } + + public string get_SubtypeName(int subtypeCode) + { + return ""; //FIXME + } + + public void set_DefaultValue(int ubtypeCode, string fieldName, object value) + { + + } + + public void set_Domain(int ubtypeCode, string fieldName, IDomain domain) + { + + } + + public IRow CreateRow() + { + Debug.WriteLine("PostGISFeatureClass::CreateRow()"); + return CreateRowBuffer() as IRow; + } + + public IRowBuffer CreateRowBuffer() + { + Debug.WriteLine("PostGISFeatureClass::CreateRowBuffer()"); + return CreateFeature() as IRowBuffer; + } + + public void DeleteSearchedRows(IQueryFilter queryFilter) + { + + } + + public IRow GetRow(int oid) + { + Debug.WriteLine("PostGISFeatureClass::GetRow"); + ICursor cur = GetRows(new int[] { oid }, false); + return cur.NextRow(); + } + + public ICursor GetRows(object oids_obj, bool recycling) + { + Debug.WriteLine("PostGISFeatureClass::GetRows"); + return (ICursor)GetFeatures(oids_obj, recycling); + } + + public int RowCount(IQueryFilter queryFilter) + { + return FeatureCount(queryFilter); + } + + public void UpdateSearchedRows(IQueryFilter queryFilter, IRowBuffer buffer) + { + + } + + /// <summary> + /// From ITableCapabilities + /// </summary> + public bool CanSelect + { + get + { + return true; + } + } + + public void AddClass(IClass classToAdd, double Weight, int XYRank, int ZRank, bool EventNotificationOnValidate) + { + + } + + public ITopologyGraph Cache + { + get + { + return null; //FIXME + } + } + + public double ClusterTolerance + { + get + { + return 0.0001; // FIXME + } + } + + public int MaximumGeneratedErrorCount + { + get + { + return 0; // FIXME + } + } + + public void RemoveClass(IClass classToRemove) + { + + } + + public esriTopologyState State + { + get + { + return esriTopologyState.esriTSUnanalyzed; // FIXME + } + } + + public int TopologyID + { + get + { + return 0; //FIXME + } + } + + public IEnvelope ValidateTopology(IEnvelope areaToValidate) + { + return null; //FIXME + } + + public IPolygon get_DirtyArea(IPolygon location) + { + return null; //FIXME + } + + public void AddRule(IRule Rule) + { + + } + + public void DeleteRule(IRule Rule) + { + + } + + public IEnumRule Rules + { + get + { + return null; // FIXME + } + } + + public ISelectionSet Validate(IQueryFilter Selection, IWorkspace Workspace) + { + return null; + } + + public ISelectionSet ValidateSelection(ISelectionSet Selection, IWorkspace Workspace) + { + return null; // FIXME + } + + public ISet ValidateSet(ISet Selection) + { + return null; + } + + public IEnumRule get_RulesByField(string FieldName) + { + return null; + } + + public IEnumRule get_RulesBySubtypeCode(int SubtypeCode) + { + return null; + } + + public void AlterRule(IRule Rule) + { + + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/Feature/FeatureClassName.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,54 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ESRI.ArcGIS.esriSystem; +using ESRI.ArcGIS.Geometry; + +namespace Postarc.Feature +{ + class FeatureClassName : IName + { + private string nameString = "UnamedPostGISFeatureClassName"; + + public string NameString + { + get + { + return nameString; + } + set + { + nameString = value; + } + } + + public object Open() + { + return new FeatureClass(esriGeometryType.esriGeometryPoint); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/Feature/FeatureCursor.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,214 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using ESRI.ArcGIS.Geodatabase; +using System.Text; +using Npgsql; +using System.Diagnostics; + +namespace Postarc.Feature +{ + static class StringExtension + { + public static string Replace(this string str, string oldValue, string newValue, StringComparison comparison) + { + StringBuilder sb = new StringBuilder(); + + int previousIndex = 0; + int index = str.IndexOf(oldValue, comparison); + while (index != -1) + { + sb.Append(str.Substring(previousIndex, index - previousIndex)); + sb.Append(newValue); + index += oldValue.Length; + + previousIndex = index; + index = str.IndexOf(oldValue, index, comparison); + } + sb.Append(str.Substring(previousIndex)); + + return sb.ToString(); + } + } + + class FeatureCursor : IFeatureCursor, ICursor + { + /// <summary> + /// Currently Postarc requires an Postarc_ID column in the PostGIS table + /// which is mapped to ArcGIS' OID. + /// </summary> + public const string POSTARC_OID_COLUMN = "oid"; + public const string POSTARC_SHAPE_COLUMN = "shape"; + public const string ARCGIS_OID_COLUMN = "oid"; + + protected PostGISConnection connection; + protected NpgsqlConnection npgsqlConnection; + protected FeatureClass featureClass; + protected IFields fields; + protected NpgsqlDataReader reader; + + private int oidIdx = -1; + + public FeatureCursor(FeatureClass featClass, PostGISConnection conn, IQueryFilter filter) + { + this.featureClass = featClass; + this.connection = conn; + + // If a QueryFilter is given, we must adapt our SQL query + string subFields = AllFields(); + string whereClause = ""; + if (filter != null) + { + /*if (!filter.SubFields.Equals("*")) + { + subFields = filter.SubFields; + if (!subFields.Contains(POSTARC_OID_COLUMN) && !subFields.Equals("*")) + { + subFields = subFields + "," + POSTARC_OID_COLUMN; + } + }*/ + + whereClause = filter.WhereClause; + if(whereClause != null && !whereClause.Equals("")) + { + whereClause = " WHERE " + whereClause; + } + } + + subFields = subFields.Replace( + POSTARC_SHAPE_COLUMN, + "ST_AsText(" + POSTARC_SHAPE_COLUMN + ") AS " + POSTARC_SHAPE_COLUMN); + + this.npgsqlConnection = conn.Open(); + NpgsqlCommand cmd = new NpgsqlCommand( + "SELECT " + subFields + " FROM " + featClass.TableName + whereClause + " ORDER BY " + POSTARC_OID_COLUMN, + npgsqlConnection); + this.reader = cmd.ExecuteReader(); + + // Build the fields + IFieldsEdit fieldsEdit = new FieldsClass(); + for (int n = 0; n < reader.FieldCount; n++) + { + string fieldName = reader.GetName(n); + if (fieldName.Equals(POSTARC_OID_COLUMN, StringComparison.OrdinalIgnoreCase)) + { + fieldName = ARCGIS_OID_COLUMN; + oidIdx = n; + } + int fidx = featClass.FindField(fieldName); + IField field = featClass.Fields.get_Field(fidx); + fieldsEdit.AddField(field); + } + this.fields = fieldsEdit as IFields; + } + + protected string AllFields() + { + StringBuilder buf = new StringBuilder(); + + for (int n = 0; n < featureClass.Fields.FieldCount; n++) + { + buf.Append(featureClass.Fields.get_Field(n).Name); + if (n < featureClass.Fields.FieldCount - 1) + { + buf.Append(","); + } + } + + return buf.ToString(); + } + + public void DeleteFeature() + { + // Not implemented + } + + public IFields Fields + { + get + { + return this.fields; + } + } + + public int FindField(string name) + { + return this.Fields.FindField(name); + } + + public void Flush() + { + // TODO: Not implemented + } + + public object InsertFeature(IFeatureBuffer buffer) + { + Debug.WriteLine("FeatureCursor::InsertFeature(): FIXME"); + return null; // TODO: Not implemented + } + + public IFeature NextFeature() + { + if (this.reader.Read()) + { + Feature feature = new Feature(featureClass, Fields, oidIdx, this.reader); + return feature; + } + this.reader.Close(); // We've reached the last feature + return null; + } + + public void UpdateFeature(IFeature Object) + { + // TODO: Not implemented + Debug.WriteLine("FeatureCursor::UpdateFeature(): FIXME"); + } + + public void DeleteRow() + { + // TODO: Not implemented + Debug.WriteLine("FeatureCursor::DeleteRow(): FIXME"); + } + + public object InsertRow(IRowBuffer buffer) + { + // TODO: Not implemented + Debug.WriteLine("FeatureCursor::InsertRow(): FIXME"); + return null; + } + + public IRow NextRow() + { + return NextFeature(); + } + + public void UpdateRow(IRow Row) + { + // TODO: Not implemented + Debug.WriteLine("FeatureCursor::UpdateRow(): FIXME"); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/Feature/FeatureLayer.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,436 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ESRI.ArcGIS.Carto; +using ESRI.ArcGIS.Geodatabase; +using ESRI.ArcGIS.Geometry; +using ESRI.ArcGIS.esriSystem; +using ESRI.ArcGIS.Display; +using Postarc.Geodatabase; +using System.Diagnostics; + +namespace Postarc.Feature +{ + class FeatureLayer : IFeatureLayer, ITableFields, IGeoDataset, ILegendInfo + { + protected Postarc.Feature.FeatureClass featureClass = null; + protected string name = "Unamed FeatureLayer"; + protected bool cached = false; + protected bool visible = true; + protected bool selectable = true; + protected bool showTips = false; + protected ISpatialReference spatialReference = new UnknownCoordinateSystemClass(); + + private IFeatureLayer parent; + + public IEnvelope AreaOfInterest + { + get + { + EnvelopeClass env = new EnvelopeClass(); + env.XMax = 100; + env.XMin = -100; + env.YMax = 100; + env.YMin = -100; + return env as IEnvelope; + } + } + + public bool Cached + { + get + { + return this.cached; + } + set + { + this.cached = value; + } + } + + public string DataSourceType + { + get + { + return "PostGIS Feature Class"; + } + set + { + // TODO + } + } + + public string DisplayField + { + get + { + return this.featureClass.ShapeFieldName; + } + set + { + // TODO + } + } + + public FeatureLayer() + { + this.parent = new FeatureLayerClass(); + } + + ///<summary>Create a simple fill symbol by specifying a color, outline color and fill style.</summary> + /// + ///<param name="fillColor">An IRGBColor interface. The color for the inside of the fill symbol.</param> + ///<param name="fillStyle">An esriSimpleLineStyle enumeration for the inside fill symbol. Example: esriSFSSolid.</param> + ///<param name="borderColor">An IRGBColor interface. The color for the outside line border of the fill symbol.</param> + ///<param name="borderStyle">An esriSimpleLineStyle enumeration for the outside line border. Example: esriSLSSolid.</param> + ///<param name="borderWidth">A System.Double that is the width of the outside line border in points. Example: 2</param> + /// + ///<returns>An ISimpleFillSymbol interface.</returns> + /// + ///<remarks></remarks> + private ISimpleFillSymbol CreateSimpleFillSymbol( + IRgbColor fillColor, + esriSimpleFillStyle fillStyle, + IRgbColor borderColor, + esriSimpleLineStyle borderStyle, + System.Double borderWidth) + { + if (fillColor == null || fillStyle == null || borderColor == null || borderStyle == null) + { + return null; + } + ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass(); + simpleLineSymbol.Width = borderWidth; + simpleLineSymbol.Color = borderColor; + simpleLineSymbol.Style = borderStyle; + + ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass(); + simpleFillSymbol.Outline = simpleLineSymbol; + simpleFillSymbol.Style = fillStyle; + simpleFillSymbol.Color = fillColor; + + return simpleFillSymbol; + } + + public void Draw(esriDrawPhase drawPhase, IDisplay display, ITrackCancel trackCancel) + { + Debug.WriteLine("PostGISFeatureLayer::Draw(" + drawPhase + ")"); + // this.parent.Draw(drawPhase, display, trackCancel); + + switch (drawPhase) + { + case esriDrawPhase.esriDPGeography: + display.SetSymbol(get_LegendGroup(0).get_Class(0).Symbol); + + IFeatureCursor cur = featureClass.Search(null, true); + IFeature feat; + while ((feat = cur.NextFeature()) != null) + { + IPoint sp = feat.Shape as IPoint; + PointClass p = new PointClass(); + p.PutCoords(sp.X, sp.Y); + p.SpatialReference = CreateGeographicSpatialReference(); + p.Project(spatialReference); + //feat.Shape.Project(spatialReference); + display.DrawPoint(p); + } + + break; + } + } + + private double GetSymbolSize(IDisplay display, int symbolSizePixels) + { + if (display == null) + return 0; + + double symbolSize; + + // convert the symbol size from pixels to map units + ITransformation transform = display.DisplayTransformation as ITransformation; + if (transform == null) + return 0; + + double[] symbolDimensions = new double[2]; + symbolDimensions[0] = (double)symbolSizePixels; + symbolDimensions[1] = (double)symbolSizePixels; + + double[] symbolDimensionsMap = new double[2]; + + transform.TransformMeasuresFF( + esriTransformDirection.esriTransformReverse, 1, ref symbolDimensionsMap[0], ref symbolDimensions[0]); + symbolSize = symbolDimensionsMap[0]; + + return symbolSize; + } + + + /// <summary> + /// create a WGS1984 geographic coordinate system. + /// In this case, the underlying data provided by the service is in WGS1984. + /// </summary> + /// <returns></returns> + public static ISpatialReference CreateGeographicSpatialReference() + { + ISpatialReferenceFactory spatialRefFatcory = new SpatialReferenceEnvironmentClass(); + IGeographicCoordinateSystem geoCoordSys; + geoCoordSys = spatialRefFatcory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984); + //geoCoordSys.SetFalseOriginAndUnits(-180.0, -180.0, 5000000.0); + //geoCoordSys.SetZFalseOriginAndUnits(0.0, 100000.0); + //geoCoordSys.SetMFalseOriginAndUnits(0.0, 100000.0); + + return geoCoordSys as ISpatialReference; + } + + public IFeatureClass FeatureClass + { + get + { + return this.featureClass; + } + set + { + this.parent.FeatureClass = value; + this.featureClass = value as FeatureClass; + } + } + + public double MaximumScale + { + get + { + return 100; // FIXME + } + set + { + // TODO: Not implemented + } + } + + public double MinimumScale + { + get + { + return 0.01; // FIXME + } + set + { + // TODO: Not implemented + } + } + + public string Name + { + get + { + return this.name; + } + set + { + this.name = value; + } + } + + public bool ScaleSymbols + { + get + { + return false; // FIXME + } + set + { + // TODO: Not implemented + } + } + + public IFeatureCursor Search(IQueryFilter queryFilter, bool recycling) + { + return FeatureClass.Search(queryFilter, recycling); + } + + public bool Selectable + { + get + { + return selectable; + } + set + { + this.selectable = value; + } + } + + public bool ShowTips + { + get + { + return this.showTips; + } + set + { + this.showTips = value; + } + } + + public ISpatialReference SpatialReference + { + set + { + this.spatialReference = value; + } + } + + public int SupportedDrawPhases + { + get + { + return 1; + } + } + + public bool Valid + { + get + { + return true; // FIXME + } + } + + public bool Visible + { + get + { + return this.visible; + } + set + { + this.visible = value; + } + } + + public string get_TipText(double x, double y, double Tolerance) + { + return "tiptext"; + } + + public int FieldCount + { + get + { + return this.featureClass.Fields.FieldCount; + } + } + + public IField get_Field(int index) + { + return this.featureClass.Fields.get_Field(index); + } + + public IFieldInfo get_FieldInfo(int index) + { + return Postarc.Geodatabase.FieldInfo.Create(get_Field(index)); + } + + public int FindField(string fieldName) + { + return this.featureClass.FindField(fieldName); + } + + + public IEnvelope Extent + { + get + { + return featureClass.Extent; + } + } + + ISpatialReference IGeoDataset.SpatialReference + { + get + { + return this.spatialReference; + } + } + + public int LegendGroupCount + { + get + { + return 1; + } + } + + public ILegendItem LegendItem + { + get + { + return null; + } + } + + public bool SymbolsAreGraduated + { + get + { + return true; + } + set + { + throw new NotImplementedException(); + } + } + + public ILegendGroup get_LegendGroup(int index) + { + if (index == 0) + { + RgbColorClass fillColor = new RgbColorClass(); + fillColor.Blue = 255; + fillColor.Red = 0; + fillColor.Green = 0; + + ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass(); + simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle; + simpleMarkerSymbol.Size = 5; + simpleMarkerSymbol.Color = fillColor; + + LegendGroupClass legGrp = new LegendGroupClass(); + legGrp.Editable = true; + legGrp.Visible = true; + + LegendClassClass legClass = new LegendClassClass(); + legClass.Description = "Point Description"; + legClass.Label = "Points"; + legClass.Symbol = (ISymbol)simpleMarkerSymbol; + legGrp.AddClass(legClass); + return legGrp; + } + return null; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/Feature/IWKTGeometry.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,50 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ESRI.ArcGIS.Geometry; + +namespace Postarc.Feature +{ + public interface IWKTGeometry : IGeometry + { + /// <summary> + /// Generates and returns the Well-Known-Text (WKT) + /// representation of this Geometry. + /// </summary> + /// <returns> + /// Well-Known-Text representation of this geometry + /// </returns> + string GetWKT(); + + /// <summary> + /// Updates this Geometry with the given Well-Known-Text (WKT) + /// representation. + /// </summary> + /// <param name="wkt">Well-Known-Text geometry representation</param> + void SetWKT(string wkt); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/Feature/Point.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,419 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ESRI.ArcGIS.Geometry; +using NpgsqlTypes; +using System.Globalization; +using ESRI.ArcGIS.Geodatabase; +using System.Diagnostics; +using ESRI.ArcGIS.esriSystem; + +namespace Postarc.Feature +{ + public class Point : + IWKTGeometry, + IGeometryDef, + IPoint, + IGeometry, + IGeometry2, + IGeometry3, + IGeometry4, + IGeometry5, + IClone, + IConstructPoint, + IConstructPoint2 + { + protected PointClass point = new PointClass(); + + public double X + { + get + { + return this.point.X; + } + set + { + this.point.X = value; + } + } + + public double Y + { + get + { + return this.point.Y; + } + set + { + this.point.Y = Y; + } + } + + public double Z + { + get + { + return point.Z; + } + set + { + this.point.Z = value; + } + } + + public Point() + { + this.point.SpatialReference = FeatureLayer.CreateGeographicSpatialReference(); + this.point.PutCoords(0, 0); + } + + public Point(IPoint point) + { + this.point.SpatialReference = point.SpatialReference; + this.point.PutCoords(point.X, point.Y); + } + + /// <summary> + /// Compares X, Y, M, Z, ID (in order) of this point with + /// otherPoint's respective values. + /// </summary> + /// <param name="otherPoint"></param> + /// <returns> + /// 0 if equal, 1 if this point is greater, -1 if smaller + /// </returns> + public int Compare(IPoint otherPoint) + { + return this.point.Compare(otherPoint); + } + + public void ConstrainAngle(double constraintAngle, IPoint anchor, bool allowOpposite) + { + this.point.ConstrainAngle(constraintAngle, anchor, allowOpposite); + } + + public void ConstrainDistance(double constraintRadius, IPoint anchor) + { + this.point.ConstrainDistance(constraintRadius, anchor); + } + + public esriGeometryDimension Dimension + { + get + { + // A point has no dimension + return this.point.Dimension; + } + } + + /// <summary> + /// Creates and returns an envelope of this point. + /// </summary> + public IEnvelope Envelope + { + get + { + return this.point.Envelope; + } + } + + public void GeoNormalize() + { + this.point.GeoNormalize(); + } + + public void GeoNormalizeFromLongitude(double longitude) + { + this.point.GeoNormalizeFromLongitude(longitude); + } + + public esriGeometryType GeometryType + { + get + { + return esriGeometryType.esriGeometryPoint; + } + } + + public int ID + { + get + { + return this.point.ID; + } + set + { + this.point.ID = value; + } + } + + public bool IsEmpty + { + get + { + return this.point.IsEmpty; + } + } + + public double M + { + get + { + return this.point.M; + } + set + { + this.point.M = value; + } + } + + public void Project(ISpatialReference newReferenceSystem) + { + this.point.Project(newReferenceSystem); + } + + public void PutCoords(double X, double Y) + { + this.point.X = X; + this.point.Y = Y; + } + + public void QueryCoords(out double X, out double Y) + { + X = this.X; + Y = this.Y; + } + + public void SetEmpty() + { + this.point.X = 0; + this.point.Y = 0; + } + + public void SnapToSpatialReference() + { + this.point.SnapToSpatialReference(); + } + + public ISpatialReference SpatialReference + { + get + { + return this.point.SpatialReference; + } + set + { + Debug.WriteLine("Point::SpatialReference::set"); + this.point.SpatialReference = value; + } + } + + public double get_VertexAttribute(esriGeometryAttributes attributeType) + { + return this.point.get_VertexAttribute(attributeType); + } + + public void set_VertexAttribute(esriGeometryAttributes attributeType, double attributeValue) + { + this.point.set_VertexAttribute(attributeType, attributeValue); + } + + public string GetWKT() + { + StringBuilder wkt = new StringBuilder(); + wkt.Append("POINT("); + wkt.Append(X.ToString("r", CultureInfo.InvariantCulture)); + wkt.Append(" "); + wkt.Append(Y.ToString("r", CultureInfo.InvariantCulture)); + wkt.Append(")"); + return wkt.ToString(); + } + + public int AvgNumPoints + { + get + { + return 1; + } + } + + public int GridCount + { + get + { + return 0; + } + } + + public bool HasM + { + get + { + return false; + } + } + + public bool HasZ + { + get + { + return false; + } + } + + public double get_GridSize(int index) + { + return 0; + } + + + public void SetWKT(string wkt) + { + wkt = wkt.Split(new char[] { '(', ')' })[1]; + string[] wkts = wkt.Split(' '); + X = double.Parse(wkts[0]); + Y = double.Parse(wkts[1]); + } + + + public void QueryEnvelope(IEnvelope outEnvelope) + { + this.point.QueryEnvelope(outEnvelope); + } + + public IPoint CentroidEx + { + get { throw new NotImplementedException(); } + } + + public bool Changed + { + get + { + throw new NotImplementedException(); + } + set + { + throw new NotImplementedException(); + } + } + + public void Project5(ISpatialReference newSpatialReference, int ProjectionHint) + { + throw new NotImplementedException(); + } + + public void ProjectEx(ISpatialReference newReferenceSystem, esriTransformDirection direction, IGeoTransformation GeoTransformation, bool bAngularDensify, double maxSegmentLength, double maxDeviation) + { + throw new NotImplementedException(); + } + + public void ProjectEx5(ISpatialReference newReferenceSystem, esriTransformDirection direction, ITransformation transformation, bool bAngularDensify, double maxSegmentLength, double maxDeviation, int ProjectionHint) + { + throw new NotImplementedException(); + } + + public void QueryWKSEnvelope(out ESRI.ArcGIS.esriSystem.WKSEnvelope e) + { + throw new NotImplementedException(); + } + + public void Assign(IClone src) + { + throw new NotImplementedException(); + } + + public IClone Clone() + { + throw new NotImplementedException(); + } + + public bool IsEqual(IClone other) + { + throw new NotImplementedException(); + } + + public bool IsIdentical(IClone other) + { + throw new NotImplementedException(); + } + + public void ConstructAlong(ICurve curve, esriSegmentExtension extension, double distance, bool asRatio) + { + throw new NotImplementedException(); + } + + public void ConstructAngleBisector(IPoint from, IPoint through, IPoint to, double distance, bool useAcuteAngle) + { + throw new NotImplementedException(); + } + + public void ConstructAngleDistance(IPoint p, double inAngle, double distance) + { + throw new NotImplementedException(); + } + + public void ConstructAngleIntersection(IPoint p1, double angle1, IPoint p2, double angle2) + { + throw new NotImplementedException(); + } + + public void ConstructAverage(IPointCollection Points, esriGeometryAttributes attributeType) + { + throw new NotImplementedException(); + } + + public void ConstructDeflection(ILine baseLine, double distance, double inAngle) + { + throw new NotImplementedException(); + } + + public void ConstructDeflectionIntersection(ILine baseLine, double startAngle, double endAngle, bool OnRightSide) + { + throw new NotImplementedException(); + } + + public void ConstructOffset(ICurve curve, esriSegmentExtension extension, double distance, bool asRatio, double Offset) + { + throw new NotImplementedException(); + } + + public void ConstructParallel(ISegment Segment, esriSegmentExtension extension, IPoint start, double distance) + { + throw new NotImplementedException(); + } + + public void ConstructPerpendicular(ISegment @base, esriSegmentExtension extension, IPoint p, double distance, bool bUseLineOrientation) + { + throw new NotImplementedException(); + } + + public void ConstructThreePointResection(IPoint point1, double angleP1P2, IPoint point2, double angleP2P3, IPoint point3, out double arcAngle) + { + throw new NotImplementedException(); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/Feature/Polygon.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,246 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ESRI.ArcGIS.Geometry; + +namespace Postarc.Feature +{ + public class Polygon : IWKTGeometry, IPolygon + { + public void Close() + { + throw new NotImplementedException(); + } + + public void Densify(double maxSegmentLength, double maxDeviation) + { + throw new NotImplementedException(); + } + + public esriGeometryDimension Dimension + { + get { throw new NotImplementedException(); } + } + + public IEnvelope Envelope + { + get { throw new NotImplementedException(); } + } + + public int ExteriorRingCount + { + get { throw new NotImplementedException(); } + } + + public IRing FindExteriorRing(IRing interiorRing) + { + throw new NotImplementedException(); + } + + public IPoint FromPoint + { + get + { + throw new NotImplementedException(); + } + set + { + throw new NotImplementedException(); + } + } + + public void Generalize(double maxAllowableOffset) + { + throw new NotImplementedException(); + } + + public void GeoNormalize() + { + throw new NotImplementedException(); + } + + public void GeoNormalizeFromLongitude(double Longitude) + { + throw new NotImplementedException(); + } + + public esriGeometryType GeometryType + { + get { throw new NotImplementedException(); } + } + + public void GetSubcurve(double fromDistance, double toDistance, bool asRatio, out ICurve outSubcurve) + { + throw new NotImplementedException(); + } + + public bool IsClosed + { + get { throw new NotImplementedException(); } + } + + public bool IsEmpty + { + get { throw new NotImplementedException(); } + } + + public double Length + { + get { throw new NotImplementedException(); } + } + + public void Project(ISpatialReference newReferenceSystem) + { + throw new NotImplementedException(); + } + + public void QueryEnvelope(IEnvelope outEnvelope) + { + throw new NotImplementedException(); + } + + public void QueryExteriorRings(ref IRing exteriorRings) + { + throw new NotImplementedException(); + } + + public void QueryFromPoint(IPoint from) + { + throw new NotImplementedException(); + } + + public void QueryInteriorRings(IRing exteriorRing, ref IRing interiorRings) + { + throw new NotImplementedException(); + } + + public void QueryNormal(esriSegmentExtension extension, double DistanceAlongCurve, bool asRatio, double Length, ILine normal) + { + throw new NotImplementedException(); + } + + public void QueryPoint(esriSegmentExtension extension, double DistanceAlongCurve, bool asRatio, IPoint outPoint) + { + throw new NotImplementedException(); + } + + public void QueryPointAndDistance(esriSegmentExtension extension, IPoint inPoint, bool asRatio, IPoint outPoint, ref double DistanceAlongCurve, ref double distanceFromCurve, ref bool bRightSide) + { + throw new NotImplementedException(); + } + + public void QueryTangent(esriSegmentExtension extension, double DistanceAlongCurve, bool asRatio, double Length, ILine tangent) + { + throw new NotImplementedException(); + } + + public void QueryToPoint(IPoint to) + { + throw new NotImplementedException(); + } + + public void ReverseOrientation() + { + throw new NotImplementedException(); + } + + public void SetEmpty() + { + throw new NotImplementedException(); + } + + public void SimplifyPreserveFromTo() + { + throw new NotImplementedException(); + } + + public void Smooth(double maxAllowableOffset) + { + throw new NotImplementedException(); + } + + public void SnapToSpatialReference() + { + throw new NotImplementedException(); + } + + public ISpatialReference SpatialReference + { + get + { + throw new NotImplementedException(); + } + set + { + throw new NotImplementedException(); + } + } + + public void SplitAtDistance(double distance, bool asRatio, bool createPart, out bool SplitHappened, out int newPartIndex, out int newSegmentIndex) + { + throw new NotImplementedException(); + } + + public void SplitAtPoint(IPoint splitPoint, bool projectOnto, bool createPart, out bool SplitHappened, out int newPartIndex, out int newSegmentIndex) + { + throw new NotImplementedException(); + } + + public IPoint ToPoint + { + get + { + throw new NotImplementedException(); + } + set + { + throw new NotImplementedException(); + } + } + + public void Weed(double maxAllowableOffsetFactor) + { + throw new NotImplementedException(); + } + + public int get_InteriorRingCount(IRing exteriorRing) + { + throw new NotImplementedException(); + } + + public string GetWKT() + { + throw new NotImplementedException(); + } + + + public void SetWKT(string wkt) + { + throw new NotImplementedException(); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/Feature/Polyline.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,221 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ESRI.ArcGIS.Geometry; + +namespace Postarc.Feature +{ + public class Polyline : IWKTGeometry, IPolyline + { + public void Densify(double maxSegmentLength, double maxDeviation) + { + throw new NotImplementedException(); + } + + public esriGeometryDimension Dimension + { + get { throw new NotImplementedException(); } + } + + public IEnvelope Envelope + { + get { throw new NotImplementedException(); } + } + + public IPoint FromPoint + { + get + { + throw new NotImplementedException(); + } + set + { + throw new NotImplementedException(); + } + } + + public void Generalize(double maxAllowableOffset) + { + throw new NotImplementedException(); + } + + public void GeoNormalize() + { + throw new NotImplementedException(); + } + + public void GeoNormalizeFromLongitude(double Longitude) + { + throw new NotImplementedException(); + } + + public esriGeometryType GeometryType + { + get { throw new NotImplementedException(); } + } + + public void GetSubcurve(double fromDistance, double toDistance, bool asRatio, out ICurve outSubcurve) + { + throw new NotImplementedException(); + } + + public bool IsClosed + { + get { throw new NotImplementedException(); } + } + + public bool IsEmpty + { + get { throw new NotImplementedException(); } + } + + public double Length + { + get { throw new NotImplementedException(); } + } + + public void Project(ISpatialReference newReferenceSystem) + { + throw new NotImplementedException(); + } + + public void QueryEnvelope(IEnvelope outEnvelope) + { + throw new NotImplementedException(); + } + + public void QueryFromPoint(IPoint from) + { + throw new NotImplementedException(); + } + + public void QueryNormal(esriSegmentExtension extension, double DistanceAlongCurve, bool asRatio, double Length, ILine normal) + { + throw new NotImplementedException(); + } + + public void QueryPoint(esriSegmentExtension extension, double DistanceAlongCurve, bool asRatio, IPoint outPoint) + { + throw new NotImplementedException(); + } + + public void QueryPointAndDistance(esriSegmentExtension extension, IPoint inPoint, bool asRatio, IPoint outPoint, ref double DistanceAlongCurve, ref double distanceFromCurve, ref bool bRightSide) + { + throw new NotImplementedException(); + } + + public void QueryTangent(esriSegmentExtension extension, double DistanceAlongCurve, bool asRatio, double Length, ILine tangent) + { + throw new NotImplementedException(); + } + + public void QueryToPoint(IPoint to) + { + throw new NotImplementedException(); + } + + public bool Reshape(IPath reshapeSource) + { + throw new NotImplementedException(); + } + + public void ReverseOrientation() + { + throw new NotImplementedException(); + } + + public void SetEmpty() + { + throw new NotImplementedException(); + } + + public void SimplifyNetwork() + { + throw new NotImplementedException(); + } + + public void Smooth(double maxAllowableOffset) + { + throw new NotImplementedException(); + } + + public void SnapToSpatialReference() + { + throw new NotImplementedException(); + } + + public ISpatialReference SpatialReference + { + get + { + throw new NotImplementedException(); + } + set + { + throw new NotImplementedException(); + } + } + + public void SplitAtDistance(double distance, bool asRatio, bool createPart, out bool SplitHappened, out int newPartIndex, out int newSegmentIndex) + { + throw new NotImplementedException(); + } + + public void SplitAtPoint(IPoint splitPoint, bool projectOnto, bool createPart, out bool SplitHappened, out int newPartIndex, out int newSegmentIndex) + { + throw new NotImplementedException(); + } + + public IPoint ToPoint + { + get + { + throw new NotImplementedException(); + } + set + { + throw new NotImplementedException(); + } + } + + public void Weed(double maxAllowableOffsetFactor) + { + throw new NotImplementedException(); + } + + public string GetWKT() + { + throw new NotImplementedException(); + } + + + public void SetWKT(string wkt) + { + throw new NotImplementedException(); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/Feature/Workspace.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,166 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ESRI.ArcGIS.Geodatabase; +using ESRI.ArcGIS.esriSystem; +using System.Diagnostics; + +namespace Postarc.Feature +{ + public class Workspace : IWorkspace, IWorkspaceEdit + { + protected WorkspaceFactory workspaceFactory = new WorkspaceFactory(); + protected bool isBeingEdited = false; + protected bool hasEdits = false; + + public IPropertySet ConnectionProperties + { + get + { + PropertySetClass props = new PropertySetClass(); + return (IPropertySet)props; + } + } + + public void ExecuteSQL(string sqlStmt) + { + throw new NotImplementedException(); + } + + public bool Exists() + { + throw new NotImplementedException(); + } + + public bool IsDirectory() + { + return false; + } + + /// <summary> + /// Returns always null as this is a remote workspace. + /// </summary> + public string PathName + { + get + { + return null; + } + } + + public esriWorkspaceType Type + { + get + { + return esriWorkspaceType.esriRemoteDatabaseWorkspace; + } + } + + public IWorkspaceFactory WorkspaceFactory + { + get + { + return this.workspaceFactory; + } + } + + public IEnumDatasetName get_DatasetNames(esriDatasetType DatasetType) + { + throw new NotImplementedException(); + } + + public IEnumDataset get_Datasets(esriDatasetType DatasetType) + { + throw new NotImplementedException(); + } + + public void AbortEditOperation() + { + Debug.WriteLine("Workspace::AbortEditOperation(): FIXME"); + } + + public void DisableUndoRedo() + { + throw new NotImplementedException(); + } + + public void EnableUndoRedo() + { + throw new NotImplementedException(); + } + + public void HasEdits(ref bool hasEdits) + { + hasEdits = this.hasEdits; + } + + public void HasRedos(ref bool hasRedos) + { + hasRedos = false; // TODO + } + + public void HasUndos(ref bool hasUndos) + { + hasUndos = false; // TODO + } + + public bool IsBeingEdited() + { + return this.isBeingEdited; + } + + public void RedoEditOperation() + { + throw new NotImplementedException(); + } + + public void StartEditOperation() + { + Debug.WriteLine("Workspace::StartEditOperation"); + } + + public void StartEditing(bool withUndoRedo) + { + this.isBeingEdited = true; + } + + public void StopEditOperation() + { + Debug.WriteLine("Workspace::StopEditOperation"); + } + + public void StopEditing(bool saveEdits) + { + this.isBeingEdited = false; + } + + public void UndoEditOperation() + { + throw new NotImplementedException(); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/Feature/WorkspaceFactory.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,101 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Runtime.InteropServices; +using ESRI.ArcGIS.Geodatabase; +using ESRI.ArcGIS.esriSystem; + +namespace Postarc.Feature +{ + [Guid("28FB48CA-697A-4E30-80B1-E4424E9A4C4D")] + public class WorkspaceFactory : IWorkspaceFactory + { + private string clsid = "{28FB48CA-697A-4E30-80B1-E4424E9A4C4D}"; + + public bool ContainsWorkspace(string parentDirectory, IFileNames fileNames) + { + throw new NotImplementedException(); + } + + public bool Copy(IWorkspaceName workspaceName, string destinationFolder, out IWorkspaceName workspaceNameCopy) + { + throw new NotImplementedException(); + } + + public IWorkspaceName Create(string parentDirectory, string Name, IPropertySet connectionProperties, int hWnd) + { + throw new NotImplementedException(); + } + + public UID GetClassID() + { + UID uid = new UID(); + uid.Value = clsid; + return uid; + } + + public IWorkspaceName GetWorkspaceName(string parentDirectory, ESRI.ArcGIS.esriSystem.IFileNames fileNames) + { + throw new NotImplementedException(); + } + + public bool IsWorkspace(string fileName) + { + throw new NotImplementedException(); + } + + public bool Move(IWorkspaceName WorkspaceName, string destinationFolder) + { + throw new NotImplementedException(); + } + + public IWorkspace Open(ESRI.ArcGIS.esriSystem.IPropertySet ConnectionProperties, int hWnd) + { + throw new NotImplementedException(); + } + + public IWorkspace OpenFromFile(string fileName, int hWnd) + { + throw new NotImplementedException(); + } + + public ESRI.ArcGIS.esriSystem.IPropertySet ReadConnectionPropertiesFromFile(string fileName) + { + throw new NotImplementedException(); + } + + public esriWorkspaceType WorkspaceType + { + get { throw new NotImplementedException(); } + } + + public string get_WorkspaceDescription(bool plural) + { + throw new NotImplementedException(); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/GUI/ButtonExportToPostGIS.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,62 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using ESRI.ArcGIS.Carto; + +namespace Postarc.GUI +{ + class ButtonExportToPostGIS : ESRI.ArcGIS.Desktop.AddIns.Button + { + protected override void OnClick() + { + try + { + // Determine layers in the current document + IFeatureLayer layer = ArcMap.Document.SelectedLayer as IFeatureLayer; + if (layer == null) + { + MessageBox.Show("Please select a feature layer!"); + } + else + { + FormExportToPostGIS form = new FormExportToPostGIS(layer); + form.Show(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message + "\n" + ex.StackTrace); + } + } + + protected override void OnUpdate() + { + Enabled = ArcMap.Application != null; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/GUI/ButtonNewPostGISLayer.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,55 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ESRI.ArcGIS.Carto; +using ESRI.ArcGIS.Geodatabase; +using System.Windows.Forms; + +namespace Postarc.GUI +{ + class ButtonNewPostGISLayer : ESRI.ArcGIS.Desktop.AddIns.Button + { + private FormNewPostGISFeatClass form = new FormNewPostGISFeatClass(); + + protected override void OnClick() + { + try + { + form.Show(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message + "\n" + ex.StackTrace); + } + } + + protected override void OnUpdate() + { + Enabled = ArcMap.Application != null; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/GUI/FormConnectionProperties.Designer.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,325 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +namespace Postarc.GUI +{ + partial class FormConnectionProperties + { + /// <summary> + /// Erforderliche Designervariable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Verwendete Ressourcen bereinigen. + /// </summary> + /// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Vom Windows Form-Designer generierter Code + + /// <summary> + /// Erforderliche Methode für die Designerunterstützung. + /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. + /// </summary> + private void InitializeComponent() + { + this.lblConnectionName = new System.Windows.Forms.Label(); + this.txtConnectionName = new System.Windows.Forms.TextBox(); + this.lblUser = new System.Windows.Forms.Label(); + this.lblPassword = new System.Windows.Forms.Label(); + this.txtUser = new System.Windows.Forms.TextBox(); + this.txtPassword = new System.Windows.Forms.TextBox(); + this.groupBoxServer = new System.Windows.Forms.GroupBox(); + this.numPort = new System.Windows.Forms.NumericUpDown(); + this.lblPort = new System.Windows.Forms.Label(); + this.txtHost = new System.Windows.Forms.TextBox(); + this.lblHost = new System.Windows.Forms.Label(); + this.groupBoxAuthentication = new System.Windows.Forms.GroupBox(); + this.groupBoxDatabase = new System.Windows.Forms.GroupBox(); + this.cmbDbNames = new System.Windows.Forms.ComboBox(); + this.btnLoadDbNames = new System.Windows.Forms.Button(); + this.lblDbName = new System.Windows.Forms.Label(); + this.btnCancel = new System.Windows.Forms.Button(); + this.btnSave = new System.Windows.Forms.Button(); + this.btnTestConnection = new System.Windows.Forms.Button(); + this.groupBoxServer.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numPort)).BeginInit(); + this.groupBoxAuthentication.SuspendLayout(); + this.groupBoxDatabase.SuspendLayout(); + this.SuspendLayout(); + // + // lblConnectionName + // + this.lblConnectionName.AutoSize = true; + this.lblConnectionName.Location = new System.Drawing.Point(12, 9); + this.lblConnectionName.Name = "lblConnectionName"; + this.lblConnectionName.Size = new System.Drawing.Size(95, 13); + this.lblConnectionName.TabIndex = 0; + this.lblConnectionName.Text = "Connection Name:"; + // + // txtConnectionName + // + this.txtConnectionName.Location = new System.Drawing.Point(111, 6); + this.txtConnectionName.Name = "txtConnectionName"; + this.txtConnectionName.Size = new System.Drawing.Size(306, 20); + this.txtConnectionName.TabIndex = 1; + this.txtConnectionName.Text = "Unnamed connection profile"; + // + // lblUser + // + this.lblUser.AutoSize = true; + this.lblUser.Location = new System.Drawing.Point(15, 19); + this.lblUser.Name = "lblUser"; + this.lblUser.Size = new System.Drawing.Size(32, 13); + this.lblUser.TabIndex = 4; + this.lblUser.Text = "User:"; + // + // lblPassword + // + this.lblPassword.AutoSize = true; + this.lblPassword.Location = new System.Drawing.Point(231, 19); + this.lblPassword.Name = "lblPassword"; + this.lblPassword.Size = new System.Drawing.Size(56, 13); + this.lblPassword.TabIndex = 5; + this.lblPassword.Text = "Password:"; + // + // txtUser + // + this.txtUser.Location = new System.Drawing.Point(89, 16); + this.txtUser.Name = "txtUser"; + this.txtUser.Size = new System.Drawing.Size(100, 20); + this.txtUser.TabIndex = 6; + // + // txtPassword + // + this.txtPassword.Location = new System.Drawing.Point(293, 16); + this.txtPassword.Name = "txtPassword"; + this.txtPassword.PasswordChar = '#'; + this.txtPassword.Size = new System.Drawing.Size(100, 20); + this.txtPassword.TabIndex = 7; + // + // groupBoxServer + // + this.groupBoxServer.Controls.Add(this.numPort); + this.groupBoxServer.Controls.Add(this.lblPort); + this.groupBoxServer.Controls.Add(this.txtHost); + this.groupBoxServer.Controls.Add(this.lblHost); + this.groupBoxServer.Location = new System.Drawing.Point(12, 42); + this.groupBoxServer.Name = "groupBoxServer"; + this.groupBoxServer.Size = new System.Drawing.Size(405, 74); + this.groupBoxServer.TabIndex = 8; + this.groupBoxServer.TabStop = false; + this.groupBoxServer.Text = "Server"; + // + // numPort + // + this.numPort.Location = new System.Drawing.Point(62, 44); + this.numPort.Maximum = new decimal(new int[] { + 65535, + 0, + 0, + 0}); + this.numPort.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.numPort.Name = "numPort"; + this.numPort.Size = new System.Drawing.Size(82, 20); + this.numPort.TabIndex = 8; + this.numPort.Value = new decimal(new int[] { + 5432, + 0, + 0, + 0}); + // + // lblPort + // + this.lblPort.AutoSize = true; + this.lblPort.Location = new System.Drawing.Point(15, 46); + this.lblPort.Name = "lblPort"; + this.lblPort.Size = new System.Drawing.Size(29, 13); + this.lblPort.TabIndex = 6; + this.lblPort.Text = "Port:"; + // + // txtHost + // + this.txtHost.Location = new System.Drawing.Point(62, 19); + this.txtHost.Name = "txtHost"; + this.txtHost.Size = new System.Drawing.Size(331, 20); + this.txtHost.TabIndex = 5; + this.txtHost.Text = "localhost"; + // + // lblHost + // + this.lblHost.AutoSize = true; + this.lblHost.Location = new System.Drawing.Point(15, 22); + this.lblHost.Name = "lblHost"; + this.lblHost.Size = new System.Drawing.Size(32, 13); + this.lblHost.TabIndex = 4; + this.lblHost.Text = "Host:"; + // + // groupBoxAuthentication + // + this.groupBoxAuthentication.Controls.Add(this.lblUser); + this.groupBoxAuthentication.Controls.Add(this.lblPassword); + this.groupBoxAuthentication.Controls.Add(this.txtPassword); + this.groupBoxAuthentication.Controls.Add(this.txtUser); + this.groupBoxAuthentication.Location = new System.Drawing.Point(12, 122); + this.groupBoxAuthentication.Name = "groupBoxAuthentication"; + this.groupBoxAuthentication.Size = new System.Drawing.Size(405, 51); + this.groupBoxAuthentication.TabIndex = 9; + this.groupBoxAuthentication.TabStop = false; + this.groupBoxAuthentication.Text = "Authentication"; + this.groupBoxAuthentication.Enter += new System.EventHandler(this.groupBoxAuthentication_Enter); + // + // groupBoxDatabase + // + this.groupBoxDatabase.Controls.Add(this.cmbDbNames); + this.groupBoxDatabase.Controls.Add(this.btnLoadDbNames); + this.groupBoxDatabase.Controls.Add(this.lblDbName); + this.groupBoxDatabase.Location = new System.Drawing.Point(12, 179); + this.groupBoxDatabase.Name = "groupBoxDatabase"; + this.groupBoxDatabase.Size = new System.Drawing.Size(405, 52); + this.groupBoxDatabase.TabIndex = 10; + this.groupBoxDatabase.TabStop = false; + this.groupBoxDatabase.Text = "Database"; + // + // cmbDbNames + // + this.cmbDbNames.FormattingEnabled = true; + this.cmbDbNames.Location = new System.Drawing.Point(108, 19); + this.cmbDbNames.Name = "cmbDbNames"; + this.cmbDbNames.Size = new System.Drawing.Size(210, 21); + this.cmbDbNames.TabIndex = 3; + // + // btnLoadDbNames + // + this.btnLoadDbNames.Location = new System.Drawing.Point(324, 17); + this.btnLoadDbNames.Name = "btnLoadDbNames"; + this.btnLoadDbNames.Size = new System.Drawing.Size(75, 23); + this.btnLoadDbNames.TabIndex = 2; + this.btnLoadDbNames.Text = "Load"; + this.btnLoadDbNames.UseVisualStyleBackColor = true; + // + // lblDbName + // + this.lblDbName.AutoSize = true; + this.lblDbName.Location = new System.Drawing.Point(15, 22); + this.lblDbName.Name = "lblDbName"; + this.lblDbName.Size = new System.Drawing.Size(87, 13); + this.lblDbName.TabIndex = 1; + this.lblDbName.Text = "Database Name:"; + // + // btnCancel + // + this.btnCancel.Location = new System.Drawing.Point(342, 237); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 23); + this.btnCancel.TabIndex = 11; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // btnSave + // + this.btnSave.Location = new System.Drawing.Point(261, 237); + this.btnSave.Name = "btnSave"; + this.btnSave.Size = new System.Drawing.Size(75, 23); + this.btnSave.TabIndex = 12; + this.btnSave.Text = "Save"; + this.btnSave.UseVisualStyleBackColor = true; + this.btnSave.Click += new System.EventHandler(this.btnSave_Click); + // + // btnTestConnection + // + this.btnTestConnection.Location = new System.Drawing.Point(180, 237); + this.btnTestConnection.Name = "btnTestConnection"; + this.btnTestConnection.Size = new System.Drawing.Size(75, 23); + this.btnTestConnection.TabIndex = 13; + this.btnTestConnection.Text = "Test"; + this.btnTestConnection.UseVisualStyleBackColor = true; + this.btnTestConnection.Click += new System.EventHandler(this.btnTestConnection_Click); + // + // ConnectionPropertiesForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(428, 268); + this.Controls.Add(this.btnTestConnection); + this.Controls.Add(this.btnSave); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.groupBoxDatabase); + this.Controls.Add(this.groupBoxAuthentication); + this.Controls.Add(this.groupBoxServer); + this.Controls.Add(this.txtConnectionName); + this.Controls.Add(this.lblConnectionName); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ConnectionPropertiesForm"; + this.Text = "Connection properties"; + this.groupBoxServer.ResumeLayout(false); + this.groupBoxServer.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numPort)).EndInit(); + this.groupBoxAuthentication.ResumeLayout(false); + this.groupBoxAuthentication.PerformLayout(); + this.groupBoxDatabase.ResumeLayout(false); + this.groupBoxDatabase.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label lblConnectionName; + private System.Windows.Forms.TextBox txtConnectionName; + private System.Windows.Forms.Label lblUser; + private System.Windows.Forms.Label lblPassword; + private System.Windows.Forms.TextBox txtUser; + private System.Windows.Forms.TextBox txtPassword; + private System.Windows.Forms.GroupBox groupBoxServer; + private System.Windows.Forms.Label lblPort; + private System.Windows.Forms.TextBox txtHost; + private System.Windows.Forms.Label lblHost; + private System.Windows.Forms.NumericUpDown numPort; + private System.Windows.Forms.GroupBox groupBoxAuthentication; + private System.Windows.Forms.GroupBox groupBoxDatabase; + private System.Windows.Forms.Button btnLoadDbNames; + private System.Windows.Forms.Label lblDbName; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Button btnSave; + private System.Windows.Forms.ComboBox cmbDbNames; + private System.Windows.Forms.Button btnTestConnection; + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/GUI/FormConnectionProperties.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,110 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Runtime.Serialization.Formatters.Binary; +using System.Text; +using System.Windows.Forms; +using Npgsql; + +namespace Postarc.GUI +{ + public partial class FormConnectionProperties : Form + { + private PostGISConnection conn; + + public FormConnectionProperties(PostGISConnection conn) + { + InitializeComponent(); + this.conn = conn; + + this.txtConnectionName.Text = conn.Name; + this.txtHost.Text = conn.Host; + this.txtUser.Text = conn.User; + this.txtPassword.Text = conn.Password; + this.cmbDbNames.SelectedItem = conn.Database; + this.numPort.Value = conn.Port; + } + + private void groupBoxAuthentication_Enter(object sender, EventArgs e) + { + + } + + private void btnSave_Click(object sender, EventArgs e) + { + UpdateConnectionObject(); + + // Write to application data + Directory.CreateDirectory(Application.UserAppDataPath + "\\postarc\\"); + FileStream fs = new FileStream( + Application.UserAppDataPath + "\\postarc\\" + txtConnectionName.Text + ".connprof", + FileMode.OpenOrCreate); + BinaryFormatter formatter = new BinaryFormatter(); + formatter.Serialize(fs, this.conn); + fs.Close(); + + MessageBox.Show( + "Connection profile saved!", "Save success", + MessageBoxButtons.OK, MessageBoxIcon.Information); + } + + private void btnTestConnection_Click(object sender, EventArgs e) + { + UpdateConnectionObject(); + try + { + NpgsqlConnection conn = this.conn.Open(); + conn.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + return; + } + + MessageBox.Show("Connection succeeded."); + } + + private void UpdateConnectionObject() + { + this.conn.Database = this.cmbDbNames.SelectedValue != null ? this.cmbDbNames.SelectedValue.ToString() : ""; + this.conn.Host = this.txtHost.Text; + this.conn.Name = this.txtConnectionName.Text; + this.conn.Password = this.txtPassword.Text; + this.conn.Port = Convert.ToInt16(this.numPort.Value); + this.conn.User = this.txtUser.Text; + } + + private void btnCancel_Click(object sender, EventArgs e) + { + Close(); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/GUI/FormConnectionProperties.resx Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/GUI/FormExportToPostGIS.Designer.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,163 @@ +namespace Postarc.GUI +{ + partial class FormExportToPostGIS + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.grpPostGIS = new System.Windows.Forms.GroupBox(); + this.cmbGeometryTable = new System.Windows.Forms.ComboBox(); + this.lblGeometryTable = new System.Windows.Forms.Label(); + this.cmbDatabaseConnections = new System.Windows.Forms.ComboBox(); + this.lblDatabaseConnections = new System.Windows.Forms.Label(); + this.btnEditConnections = new System.Windows.Forms.Button(); + this.btnExport = new System.Windows.Forms.Button(); + this.lblDocumentLayer = new System.Windows.Forms.Label(); + this.progressBar = new System.Windows.Forms.ProgressBar(); + this.grpPostGIS.SuspendLayout(); + this.SuspendLayout(); + // + // grpPostGIS + // + this.grpPostGIS.Controls.Add(this.cmbGeometryTable); + this.grpPostGIS.Controls.Add(this.lblGeometryTable); + this.grpPostGIS.Controls.Add(this.cmbDatabaseConnections); + this.grpPostGIS.Controls.Add(this.lblDatabaseConnections); + this.grpPostGIS.Controls.Add(this.btnEditConnections); + this.grpPostGIS.Location = new System.Drawing.Point(12, 34); + this.grpPostGIS.Name = "grpPostGIS"; + this.grpPostGIS.Size = new System.Drawing.Size(402, 91); + this.grpPostGIS.TabIndex = 8; + this.grpPostGIS.TabStop = false; + this.grpPostGIS.Text = "Destination: PostGIS"; + // + // cmbGeometryTable + // + this.cmbGeometryTable.FormattingEnabled = true; + this.cmbGeometryTable.Location = new System.Drawing.Point(128, 53); + this.cmbGeometryTable.Name = "cmbGeometryTable"; + this.cmbGeometryTable.Size = new System.Drawing.Size(207, 21); + this.cmbGeometryTable.TabIndex = 2; + this.cmbGeometryTable.Text = "new_geo_table"; + // + // lblGeometryTable + // + this.lblGeometryTable.AutoSize = true; + this.lblGeometryTable.Location = new System.Drawing.Point(10, 56); + this.lblGeometryTable.Name = "lblGeometryTable"; + this.lblGeometryTable.Size = new System.Drawing.Size(81, 13); + this.lblGeometryTable.TabIndex = 5; + this.lblGeometryTable.Text = "Geometry table:"; + // + // cmbDatabaseConnections + // + this.cmbDatabaseConnections.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cmbDatabaseConnections.FormattingEnabled = true; + this.cmbDatabaseConnections.Location = new System.Drawing.Point(128, 19); + this.cmbDatabaseConnections.Name = "cmbDatabaseConnections"; + this.cmbDatabaseConnections.Size = new System.Drawing.Size(207, 21); + this.cmbDatabaseConnections.TabIndex = 0; + // + // lblDatabaseConnections + // + this.lblDatabaseConnections.AutoSize = true; + this.lblDatabaseConnections.Location = new System.Drawing.Point(10, 22); + this.lblDatabaseConnections.Name = "lblDatabaseConnections"; + this.lblDatabaseConnections.Size = new System.Drawing.Size(112, 13); + this.lblDatabaseConnections.TabIndex = 1; + this.lblDatabaseConnections.Text = "Database connection:"; + // + // btnEditConnections + // + this.btnEditConnections.Location = new System.Drawing.Point(341, 17); + this.btnEditConnections.Name = "btnEditConnections"; + this.btnEditConnections.Size = new System.Drawing.Size(47, 23); + this.btnEditConnections.TabIndex = 1; + this.btnEditConnections.Text = "&Edit"; + this.btnEditConnections.UseVisualStyleBackColor = true; + // + // btnExport + // + this.btnExport.Location = new System.Drawing.Point(339, 131); + this.btnExport.Name = "btnExport"; + this.btnExport.Size = new System.Drawing.Size(75, 23); + this.btnExport.TabIndex = 9; + this.btnExport.Text = "&Export"; + this.btnExport.UseVisualStyleBackColor = true; + this.btnExport.Click += new System.EventHandler(this.btnExport_Click); + // + // lblDocumentLayer + // + this.lblDocumentLayer.AutoSize = true; + this.lblDocumentLayer.Location = new System.Drawing.Point(12, 9); + this.lblDocumentLayer.Name = "lblDocumentLayer"; + this.lblDocumentLayer.Size = new System.Drawing.Size(80, 13); + this.lblDocumentLayer.TabIndex = 10; + this.lblDocumentLayer.Text = "Layer to export:"; + // + // progressBar + // + this.progressBar.Location = new System.Drawing.Point(12, 131); + this.progressBar.Name = "progressBar"; + this.progressBar.Size = new System.Drawing.Size(295, 23); + this.progressBar.TabIndex = 11; + this.progressBar.Visible = false; + // + // FormExportToPostGIS + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(424, 162); + this.Controls.Add(this.progressBar); + this.Controls.Add(this.lblDocumentLayer); + this.Controls.Add(this.btnExport); + this.Controls.Add(this.grpPostGIS); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "FormExportToPostGIS"; + this.Text = "FormExportToPostGIS"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormExportToPostGIS_FormClosing); + this.grpPostGIS.ResumeLayout(false); + this.grpPostGIS.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.GroupBox grpPostGIS; + private System.Windows.Forms.Label lblGeometryTable; + private System.Windows.Forms.ComboBox cmbDatabaseConnections; + private System.Windows.Forms.Label lblDatabaseConnections; + private System.Windows.Forms.Button btnEditConnections; + private System.Windows.Forms.ComboBox cmbGeometryTable; + private System.Windows.Forms.Button btnExport; + private System.Windows.Forms.Label lblDocumentLayer; + private System.Windows.Forms.ProgressBar progressBar; + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/GUI/FormExportToPostGIS.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,77 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using ESRI.ArcGIS.Carto; +using Postarc.Catalog; + +namespace Postarc.GUI +{ + public partial class FormExportToPostGIS : Form + { + protected IFeatureLayer layer; + + public FormExportToPostGIS(IFeatureLayer layer) + { + this.layer = layer; + InitializeComponent(); + + // Fill the database connections to the combo box and preselect one + int selIndex = this.cmbDatabaseConnections.SelectedIndex; + this.cmbDatabaseConnections.Items.Clear(); + this.cmbDatabaseConnections.Items.AddRange(Settings.LoadSavedProfiles().ToArray()); + this.cmbDatabaseConnections.Items.Add(new PostGISConnection()); + this.cmbDatabaseConnections.SelectedIndex = 0; + if (selIndex >= 0) + { + this.cmbDatabaseConnections.SelectedIndex = selIndex; + } + + this.lblDocumentLayer.Text = "Layer to export: " + layer.Name; + } + + private void FormExportToPostGIS_FormClosing(object sender, FormClosingEventArgs e) + { + e.Cancel = true; + Visible = false; + } + + private void btnExport_Click(object sender, EventArgs e) + { + PostGISConnection conn = this.cmbDatabaseConnections.SelectedItem as PostGISConnection; + + FeatureClassExporter exp = new FeatureClassExporter(layer.FeatureClass); + int numExported = exp.ExportFeatureClass(null, conn, cmbGeometryTable.Text); + + MessageBox.Show(numExported + " features exported!", "Export successful", MessageBoxButtons.OK, MessageBoxIcon.Information); + Visible = false; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/GUI/FormExportToPostGIS.resx Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/GUI/FormNewPostGISFeatClass.Designer.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,254 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +namespace Postarc.GUI +{ + partial class FormNewPostGISFeatClass + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.cmbDatabaseConnections = new System.Windows.Forms.ComboBox(); + this.lblDatabaseConnections = new System.Windows.Forms.Label(); + this.grpFeatureClass = new System.Windows.Forms.GroupBox(); + this.txtFCName = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.cmbGeometryType = new System.Windows.Forms.ComboBox(); + this.label3 = new System.Windows.Forms.Label(); + this.txtLayerName = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.btnEditConnections = new System.Windows.Forms.Button(); + this.btnCreate = new System.Windows.Forms.Button(); + this.grpPostGIS = new System.Windows.Forms.GroupBox(); + this.cmbGeometryTable = new System.Windows.Forms.ComboBox(); + this.lblGeometryTable = new System.Windows.Forms.Label(); + this.grpFeatureClass.SuspendLayout(); + this.grpPostGIS.SuspendLayout(); + this.SuspendLayout(); + // + // cmbDatabaseConnections + // + this.cmbDatabaseConnections.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cmbDatabaseConnections.FormattingEnabled = true; + this.cmbDatabaseConnections.Location = new System.Drawing.Point(128, 19); + this.cmbDatabaseConnections.Name = "cmbDatabaseConnections"; + this.cmbDatabaseConnections.Size = new System.Drawing.Size(207, 21); + this.cmbDatabaseConnections.TabIndex = 0; + this.cmbDatabaseConnections.SelectedIndexChanged += new System.EventHandler(this.cmbDatabaseConnections_SelectedIndexChanged); + // + // lblDatabaseConnections + // + this.lblDatabaseConnections.AutoSize = true; + this.lblDatabaseConnections.Location = new System.Drawing.Point(10, 22); + this.lblDatabaseConnections.Name = "lblDatabaseConnections"; + this.lblDatabaseConnections.Size = new System.Drawing.Size(112, 13); + this.lblDatabaseConnections.TabIndex = 1; + this.lblDatabaseConnections.Text = "Database connection:"; + // + // grpFeatureClass + // + this.grpFeatureClass.Controls.Add(this.txtFCName); + this.grpFeatureClass.Controls.Add(this.label4); + this.grpFeatureClass.Controls.Add(this.cmbGeometryType); + this.grpFeatureClass.Controls.Add(this.label3); + this.grpFeatureClass.Controls.Add(this.txtLayerName); + this.grpFeatureClass.Controls.Add(this.label2); + this.grpFeatureClass.Location = new System.Drawing.Point(12, 109); + this.grpFeatureClass.Name = "grpFeatureClass"; + this.grpFeatureClass.Size = new System.Drawing.Size(402, 106); + this.grpFeatureClass.TabIndex = 3; + this.grpFeatureClass.TabStop = false; + this.grpFeatureClass.Text = "FeatureClass Properties"; + // + // txtFCName + // + this.txtFCName.Location = new System.Drawing.Point(115, 45); + this.txtFCName.Name = "txtFCName"; + this.txtFCName.Size = new System.Drawing.Size(269, 20); + this.txtFCName.TabIndex = 4; + this.txtFCName.Text = "NewFeatureClass"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(9, 48); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(100, 13); + this.label4.TabIndex = 7; + this.label4.Text = "FeatureClass name:"; + // + // cmbGeometryType + // + this.cmbGeometryType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cmbGeometryType.FormattingEnabled = true; + this.cmbGeometryType.Items.AddRange(new object[] { + "POINT", + "POLYGON", + "POLYLINE"}); + this.cmbGeometryType.Location = new System.Drawing.Point(115, 71); + this.cmbGeometryType.Name = "cmbGeometryType"; + this.cmbGeometryType.Size = new System.Drawing.Size(121, 21); + this.cmbGeometryType.TabIndex = 5; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(9, 74); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(78, 13); + this.label3.TabIndex = 5; + this.label3.Text = "Geometry type:"; + // + // txtLayerName + // + this.txtLayerName.Location = new System.Drawing.Point(115, 19); + this.txtLayerName.Name = "txtLayerName"; + this.txtLayerName.Size = new System.Drawing.Size(269, 20); + this.txtLayerName.TabIndex = 3; + this.txtLayerName.Text = "Unnamed PostGIS FeatureClass"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(9, 22); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(65, 13); + this.label2.TabIndex = 3; + this.label2.Text = "Layer name:"; + // + // btnEditConnections + // + this.btnEditConnections.Location = new System.Drawing.Point(341, 17); + this.btnEditConnections.Name = "btnEditConnections"; + this.btnEditConnections.Size = new System.Drawing.Size(47, 23); + this.btnEditConnections.TabIndex = 1; + this.btnEditConnections.Text = "&Edit"; + this.btnEditConnections.UseVisualStyleBackColor = true; + this.btnEditConnections.Click += new System.EventHandler(this.btnEditConnections_Click); + // + // btnCreate + // + this.btnCreate.Location = new System.Drawing.Point(339, 221); + this.btnCreate.Name = "btnCreate"; + this.btnCreate.Size = new System.Drawing.Size(75, 23); + this.btnCreate.TabIndex = 6; + this.btnCreate.Text = "&Create"; + this.btnCreate.UseVisualStyleBackColor = true; + this.btnCreate.Click += new System.EventHandler(this.btnCreate_Click); + // + // grpPostGIS + // + this.grpPostGIS.Controls.Add(this.cmbGeometryTable); + this.grpPostGIS.Controls.Add(this.lblGeometryTable); + this.grpPostGIS.Controls.Add(this.cmbDatabaseConnections); + this.grpPostGIS.Controls.Add(this.lblDatabaseConnections); + this.grpPostGIS.Controls.Add(this.btnEditConnections); + this.grpPostGIS.Location = new System.Drawing.Point(12, 12); + this.grpPostGIS.Name = "grpPostGIS"; + this.grpPostGIS.Size = new System.Drawing.Size(402, 91); + this.grpPostGIS.TabIndex = 6; + this.grpPostGIS.TabStop = false; + this.grpPostGIS.Text = "PostGIS Properties"; + // + // cmbGeometryTable + // + this.cmbGeometryTable.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cmbGeometryTable.FormattingEnabled = true; + this.cmbGeometryTable.Location = new System.Drawing.Point(128, 53); + this.cmbGeometryTable.Name = "cmbGeometryTable"; + this.cmbGeometryTable.Size = new System.Drawing.Size(207, 21); + this.cmbGeometryTable.TabIndex = 2; + // + // lblGeometryTable + // + this.lblGeometryTable.AutoSize = true; + this.lblGeometryTable.Location = new System.Drawing.Point(10, 56); + this.lblGeometryTable.Name = "lblGeometryTable"; + this.lblGeometryTable.Size = new System.Drawing.Size(81, 13); + this.lblGeometryTable.TabIndex = 5; + this.lblGeometryTable.Text = "Geometry table:"; + // + // FormNewPostGISFeatClass + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(426, 253); + this.Controls.Add(this.grpPostGIS); + this.Controls.Add(this.btnCreate); + this.Controls.Add(this.grpFeatureClass); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "FormNewPostGISFeatClass"; + this.Text = "New PostGIS FeatureClass"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormNewPostGISFeatClass_FormClosing); + this.Shown += new System.EventHandler(this.FormNewPostGISFeatClass_Shown); + this.grpFeatureClass.ResumeLayout(false); + this.grpFeatureClass.PerformLayout(); + this.grpPostGIS.ResumeLayout(false); + this.grpPostGIS.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.ComboBox cmbDatabaseConnections; + private System.Windows.Forms.Label lblDatabaseConnections; + private System.Windows.Forms.GroupBox grpFeatureClass; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button btnEditConnections; + private System.Windows.Forms.TextBox txtLayerName; + private System.Windows.Forms.ComboBox cmbGeometryType; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox txtFCName; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Button btnCreate; + private System.Windows.Forms.GroupBox grpPostGIS; + private System.Windows.Forms.ComboBox cmbGeometryTable; + private System.Windows.Forms.Label lblGeometryTable; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/GUI/FormNewPostGISFeatClass.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,154 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using ESRI.ArcGIS.Carto; +using ESRI.ArcGIS.Geodatabase; +using ESRI.ArcGIS.Geometry; +using Postarc.Feature; + +namespace Postarc.GUI +{ + public partial class FormNewPostGISFeatClass : Form + { + public FormNewPostGISFeatClass() + { + InitializeComponent(); + this.cmbGeometryType.SelectedIndex = 0; + } + + private void btnCreate_Click(object sender, EventArgs e) + { + if (cmbGeometryType.SelectedItem == null) + { + MessageBox.Show("Please choose the Shape type of the new FeatureClass!", "Shape type", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + if (txtLayerName.Text == null || txtLayerName.Text.Equals("")) + { + MessageBox.Show("Please enter a name for the new layer!", "Layer name", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + if (txtFCName.Text == null || txtFCName.Text.Equals("")) + { + MessageBox.Show("Please enter a name for the FeatureClass!", "FeatureClass name", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + + esriGeometryType shapeType = esriGeometryType.esriGeometryNull; + if (cmbGeometryType.SelectedItem.Equals("POINT")) + { + shapeType = esriGeometryType.esriGeometryPoint; + } + else if (cmbGeometryType.SelectedItem.Equals("POLYGON")) + { + shapeType = esriGeometryType.esriGeometryPolygon; + } + else if (cmbGeometryType.SelectedItem.Equals("POLYLINE")) + { + shapeType = esriGeometryType.esriGeometryPolyline; + } + + //PostarcClassDescription.Register(); + + IFeatureClass featClass; + //if (cmbGeometryTable.SelectedText!= null) + { + featClass = new Postarc.Feature.FeatureClass( + this.cmbDatabaseConnections.SelectedItem as PostGISConnection, + this.cmbGeometryTable.SelectedItem as string); + } + //else + //{ + // featClass = new PostGISFeatureClass(shapeType); + //} + + // Load field definitions from geometry table + + Visible = false; + Application.DoEvents(); + + // Create FeatureLayer that encapsulates our FeatureClass + IFeatureLayer featLayer = new Postarc.Feature.FeatureLayer(); + featLayer.FeatureClass = featClass; + featLayer.Name = txtLayerName.Text; + + // Add FeatureLayer to active map document + ArcMap.Document.FocusMap.AddLayer(featLayer); + } + + private void btnEditConnections_Click(object sender, EventArgs e) + { + PostGISConnection conn = this.cmbDatabaseConnections.SelectedItem as PostGISConnection; + if (conn != null) + { + FormConnectionProperties connProp = new FormConnectionProperties(conn); + connProp.ShowDialog(); + } + else + { + MessageBox.Show("Please select a connection profile first!"); + } + } + + private void FormNewPostGISFeatClass_Shown(object sender, EventArgs e) + { + int selIndex; + + // Fill the database connections to the combo box and preselect one + selIndex = this.cmbDatabaseConnections.SelectedIndex; + this.cmbDatabaseConnections.Items.Clear(); + this.cmbDatabaseConnections.Items.AddRange(Settings.LoadSavedProfiles().ToArray()); + this.cmbDatabaseConnections.Items.Add(new PostGISConnection()); + this.cmbDatabaseConnections.SelectedIndex = 0; + if (selIndex >= 0) + { + this.cmbDatabaseConnections.SelectedIndex = selIndex; + } + } + + private void FormNewPostGISFeatClass_FormClosing(object sender, FormClosingEventArgs e) + { + e.Cancel = true; + Visible = false; + } + + private void cmbDatabaseConnections_SelectedIndexChanged(object sender, EventArgs e) + { + if (cmbDatabaseConnections.SelectedIndex >= 0) + { + PostGISConnection conn = cmbDatabaseConnections.SelectedItem as PostGISConnection; + this.cmbGeometryTable.Items.Clear(); + this.cmbGeometryTable.Items.AddRange(conn.QueryTables().ToArray()); + this.cmbGeometryTable.SelectedIndex = 0; + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/GUI/FormNewPostGISFeatClass.resx Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/Geodatabase/DummyClassExtension.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ESRI.ArcGIS.Geodatabase; + +namespace Postarc.Geodatabase +{ + public class DummyClassExtension : IClassExtension + { + public void Init(IClassHelper ClassHelper, ESRI.ArcGIS.esriSystem.IPropertySet ExtensionProperties) + { + return; + } + + public void Shutdown() + { + return; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/Geodatabase/FeatureDataset.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ESRI.ArcGIS.Geodatabase; + +namespace Postarc.Geodatabase +{ + public class FeatureDataset : IFeatureDataset + { + protected Postarc.Feature.FeatureClass featureClass; + + public FeatureDataset(Postarc.Feature.FeatureClass featureClass) + { + this.featureClass = featureClass; + } + + public string BrowseName + { + get + { + throw new NotImplementedException(); + } + set + { + throw new NotImplementedException(); + } + } + + public bool CanCopy() + { + throw new NotImplementedException(); + } + + public bool CanDelete() + { + throw new NotImplementedException(); + } + + public bool CanRename() + { + throw new NotImplementedException(); + } + + public string Category + { + get { throw new NotImplementedException(); } + } + + public IDataset Copy(string copyName, IWorkspace copyWorkspace) + { + throw new NotImplementedException(); + } + + public IFeatureClass CreateFeatureClass(string Name, IFields Fields, ESRI.ArcGIS.esriSystem.UID CLSID, ESRI.ArcGIS.esriSystem.UID EXTCLSID, esriFeatureType FeatureType, string ShapeFieldName, string ConfigKeyword) + { + throw new NotImplementedException(); + } + + public void Delete() + { + throw new NotImplementedException(); + } + + public ESRI.ArcGIS.esriSystem.IName FullName + { + get { throw new NotImplementedException(); } + } + + public string Name + { + get + { + return this.featureClass.Name + " Dataset"; + } + } + + public ESRI.ArcGIS.esriSystem.IPropertySet PropertySet + { + get { throw new NotImplementedException(); } + } + + public void Rename(string Name) + { + throw new NotImplementedException(); + } + + public IEnumDataset Subsets + { + get { throw new NotImplementedException(); } + } + + public esriDatasetType Type + { + get + { + return esriDatasetType.esriDTFeatureClass; + } + } + + public IWorkspace Workspace + { + get + { + return this.featureClass.Workspace; + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/Geodatabase/FieldInfo.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ESRI.ArcGIS.Geodatabase; +using ESRI.ArcGIS.esriSystem; + +namespace Postarc.Geodatabase +{ + public class FieldInfo : IFieldInfo + { + protected string alias = null; + protected INumberFormat numberFormat = null; + protected bool visible = true; + + public static IFieldInfo Create(IField field) + { + return new FieldInfo(field); + } + + protected FieldInfo(IField field) + { + Alias = field.AliasName; + switch (field.Type) + { + case esriFieldType.esriFieldTypeInteger: + case esriFieldType.esriFieldTypeSmallInteger: + this.numberFormat = new NumericFormatClass(); + break; + } + } + + public string Alias + { + get + { + return this.alias; + } + set + { + this.alias = value; + } + } + + public INumberFormat NumberFormat + { + get + { + return this.numberFormat; + } + set + { + this.numberFormat = value; + } + } + + public bool Visible + { + get + { + return this.visible; + } + set + { + this.visible = value; + } + } + + public string get_AsString(object value) + { + if (value == null) + { + return "<NULL>"; + } + else + { + return value.ToString(); + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/Geodatabase/SelectionSet.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,146 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ESRI.ArcGIS.Geodatabase; + +namespace Postarc.Geodatabase +{ + public class SelectionSet : ISelectionSet + { + protected Postarc.Feature.FeatureClass featureClass; + protected List<int> list = new List<int>(); + + internal List<int> List + { + get + { + return this.list; + } + } + + public SelectionSet(Postarc.Feature.FeatureClass featureClass) + { + this.featureClass = featureClass; + } + + public void Add(int oid) + { + this.list.Add(oid); + } + + /// <summary> + /// Do not call this method, says API... okay... + /// </summary> + /// <param name="Count"></param> + /// <param name="OIDList"></param> + public void AddList(int Count, ref int OIDList) + { + // Does nothing + } + + public void Combine(ISelectionSet otherSet, esriSetOperation setOp, out ISelectionSet resultSet) + { + SelectionSet newSet = new SelectionSet(featureClass); + newSet.list.AddRange(list); + newSet.list.AddRange(((SelectionSet)otherSet).list); + resultSet = newSet as ISelectionSet; + } + + public int Count + { + get + { + return this.list.Count; + } + } + + /// <summary> + /// Always returns null. + /// </summary> + public ESRI.ArcGIS.esriSystem.IName FullName + { + get + { + return null; + } + } + + public IEnumIDs IDs + { + get + { + return new SelectionSetEnumerator(this); + } + } + + /// <summary> + /// Not implemented. + /// </summary> + public void MakePermanent() + { + throw new NotImplementedException(); + } + + public void Refresh() + { + + } + + /// <summary> + /// Do not call + /// </summary> + /// <param name="Count"></param> + /// <param name="OIDList"></param> + public void RemoveList(int count, ref int oidList) + { + + } + + public void Search(IQueryFilter queryFilter, bool recycling, out ICursor cursor) + { + // TODO: Merge queryFilter with this SelectionSet + cursor = featureClass.Search(queryFilter, recycling) as ICursor; + } + + public ISelectionSet Select( + IQueryFilter queryFilter, + esriSelectionType selType, + esriSelectionOption selOption, + IWorkspace selectionContainer) + { + throw new NotImplementedException(); + } + + public ITable Target + { + get + { + return this.featureClass; + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/Geodatabase/SelectionSetEnumerator.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ESRI.ArcGIS.Geodatabase; + +namespace Postarc.Geodatabase +{ + class SelectionSetEnumerator : IEnumIDs + { + protected SelectionSet set; + protected int next = 0; + + public SelectionSetEnumerator(SelectionSet set) + { + this.set = set; + } + + public int Next() + { + if (set.Count < next) + { + return set.List[next++]; + } + return -1; + } + + public void Reset() + { + this.next = 0; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/PostArcCOMHelper.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,67 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Runtime.InteropServices; +using ESRI.ArcGIS.ADF.CATIDs; +using Postarc.Catalog; +using Postarc.Feature; + +namespace Postarc +{ + public class PostarcCOMHelper + { + #region COM Registration + + [ComRegisterFunction] + static void Register(string key) + { + //System.Windows.Forms.MessageBox.Show("Postarc::Register(" + key + ")"); + + // Register PostGISFeatureClass + System.Type type = typeof(PostarcClassDescription); + GeoObjectClassExtensions.Register(type.GUID.ToString()); + GeoObjectClassDescriptions.Register(type.GUID.ToString()); + + //System.Windows.Forms.MessageBox.Show(type.GUID.ToString()); + + // Register ArcCatalog extension + type = typeof(GxAddNewPostGISConnection); + GxFolderNewMenuCommands.Register(type.GUID.ToString()); + GxDatabaseExtensions.Register(type.GUID.ToString()); + GxRootObjects.Register(type.GUID.ToString()); + } + + [ComUnregisterFunction] + static void Unregister(string key) + { + ESRI.ArcGIS.ADF.CATIDs.GeoObjectClassExtensions.Unregister(key); + ESRI.ArcGIS.ADF.CATIDs.GeoObjectClassDescriptions.Unregister(key); + } + + #endregion + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/PostArcClassDescription.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,111 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ESRI.ArcGIS.Geodatabase; +using ESRI.ArcGIS.ADF.CATIDs; +using System.Runtime.InteropServices; + +namespace Postarc +{ + /// <summary> + /// Provides configuration information for ArcCatalog when creating new object or feature classes. + /// The class description can be registered using the GeoObjectClassDescriptions static class in the ESRI.ArcGIS.ADF.CATIDs namespace. + /// </summary> + [Guid("4D5457B8-7378-4457-8FD8-7D6553A93EDD")] + public class PostarcClassDescription : IObjectClassDescription, IFeatureClassDescription + { + public string AliasName + { + get + { + return "Postarc Feature Alias Name"; + } + } + + public ESRI.ArcGIS.esriSystem.UID ClassExtensionCLSID + { + get { return null; } // No class extension + } + + public ESRI.ArcGIS.esriSystem.UID InstanceCLSID + { + get { throw new NotImplementedException(); } + } + + public string ModelName + { + get { throw new NotImplementedException(); } + } + + public bool ModelNameUnique + { + get { throw new NotImplementedException(); } + } + + public string Name + { + get + { + return "ClassDescription_CustomClass"; + } + } + + public IFields RequiredFields + { + get + { + IFieldsEdit fields = new FieldsClass(); + + IFieldEdit field = new FieldClass(); + field.Name_2 = "Shape"; + field.Type_2 = esriFieldType.esriFieldTypeGeometry; + fields.set_Field(1, field); + + return fields; + } + } + + /// <summary> + /// Simple features. + /// </summary> + public esriFeatureType FeatureType + { + get + { + return esriFeatureType.esriFTSimple; + } + } + + public string ShapeFieldName + { + get + { + return "Shape"; + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/PostGISConnection.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,179 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Runtime.Serialization; +using Npgsql; + +namespace Postarc +{ + [Serializable] + public class PostGISConnection + { + private string name = "<new profile>"; + private string host; + private int port = 5432; + private string user; + private string password; + private string database; + + public string Name + { + get + { + return this.name; + } + set + { + this.name = value; + } + } + + public string Host + { + get + { + return this.host; + } + set + { + this.host = value; + } + } + + public int Port + { + get + { + return this.port; + } + set + { + this.port = value; + } + } + + public string User + { + get + { + return this.user; + } + set + { + this.user = value; + } + } + + public string Password + { + get + { + return this.password; + } + set + { + this.password = value; + } + } + + public string Database + { + get + { + return "postgis"; // this.database; + } + set + { + this.database = value; + } + } + + public PostGISConnection() + { + } + + public string CreateConnectionString() + { + StringBuilder cs = new StringBuilder(); + cs.Append("Server="); cs.Append(host); + cs.Append(";Port="); cs.Append(port); + cs.Append(";User Id="); cs.Append(user); + cs.Append(";Password="); cs.Append(password); + cs.Append(";Database="); cs.Append(database); + cs.Append(";"); + return cs.ToString(); + } + + /// <summary> + /// Creates and opens an NpgsqlConnection to the PostGIS database + /// described by this PostGISConnection instance. + /// </summary> + /// <returns></returns> + public NpgsqlConnection Open() + { + NpgsqlConnection conn = new NpgsqlConnection(CreateConnectionString()); + conn.ChangeDatabase(this.Database); + return conn; + } + + /// <summary> + /// Queries the table names from the information_schema.tables table + /// of the PostgreSQL system. + /// </summary> + /// <returns></returns> + public List<string> QueryTables() + { + List<string> tables = new List<string>(); + + NpgsqlConnection conn = Open(); + NpgsqlCommand cmd = new NpgsqlCommand( + "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';", + conn); + NpgsqlDataReader reader = cmd.ExecuteReader(); + while (reader.Read()) + { + string str = reader.GetString(0); + if (!str.Equals("spatial_ref_sys") && + !str.Equals("geography_columns") && + !str.Equals("geometry_columns") && + !str.Equals("raster_columns") && + !str.Equals("raster_overviews")) + { + tables.Add(str); + } + } + + conn.Close(); + return tables; + } + + public override string ToString() + { + return Name; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/Settings.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,80 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.IO; +using System.Runtime.Serialization.Formatters.Binary; +using System.Runtime.Serialization; +using System.Reflection; + +namespace Postarc +{ + public class Settings + { + public class Binder : SerializationBinder + { + public override Type BindToType(string assemblyName, string typeName) + { + Type type = null; + string shortAssem = assemblyName.Split(',')[0]; + Assembly[] assemblies = + AppDomain.CurrentDomain.GetAssemblies(); + + foreach (Assembly assem in assemblies) + { + if (shortAssem == assem.FullName.Split(',')[0]) + { + type = assem.GetType(typeName); + break; + } + + } + return type; + } + + } + + public static List<PostGISConnection> LoadSavedProfiles() + { + List<PostGISConnection> profiles = new List<PostGISConnection>(); + string path = Application.UserAppDataPath + "\\postarc\\"; + + string[] files = Directory.GetFiles(path, "*.connprof"); + foreach(string file in files) + { + FileStream fs = new FileStream(file, FileMode.Open); + BinaryFormatter formatter = new BinaryFormatter(); + formatter.Binder = new Settings.Binder(); + PostGISConnection conn = (PostGISConnection)formatter.Deserialize(fs); + fs.Close(); + profiles.Add(conn); + } + + return profiles; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Properties/AssemblyInfo.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Postarc")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Intevation GmbH")] +[assembly: AssemblyProduct("Postarc")] +[assembly: AssemblyCopyright("Copyright © Intevation GmbH 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(true)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("1d7944ae-1320-4073-b318-c16e1f9b0135")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.txt Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,13 @@ +Postarc connects ArcMap with PostGIS databases. +It enables read and write access to PostGIS-powered Feature Layers. + +Postarc is Free Software licensed under the terms of the +GNU Lesser General Public License (LGPL). + +Postarc is written in C#. You'll need Microsoft Visual Studio 2010 and +ArcGIS 10 SDK for .Net to compile it and ArcMap 10 to run it. + +The connection to PostGIS/PostgreSQL is handled by the Npgsql +library which is not part of this distribution. + +Note: Postarc is work-in-progress and not really useable by now. \ No newline at end of file